Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Url.Content in asp.net web-forms

I'm trying to do this:

<a href="~/Cases/SupRequestSearch.aspx">Search request</a>

so I need the ~ to be rendered as http://myserver/app/...

in mvc I would do

<a href="<%=Url.Content("~/Cases/SupRequestSearch.aspx")%>>Search request</a>

is there something similar in asp.net web forms ?

like image 689
Omu Avatar asked Jun 13 '11 13:06

Omu


3 Answers

As rapadai mentioned above, the equivalent of

Url.Content("~/path/to/file.ext") // MVC

in webforms is

Page.ResolveUrl("~/path/to/file.ext") // Webforms
like image 133
Ben Cull Avatar answered Oct 18 '22 03:10

Ben Cull


Try adding runat="server" to your tag.

like image 12
Daniel A. White Avatar answered Oct 18 '22 04:10

Daniel A. White


Try this:

<asp:hyperlink  id="Search" NavigateUrl="~/Cases/SupRequestSearch.aspx" runat="server" />

or just

<a href="~/Cases/SupRequestSearch.aspx" id="Search" runat="server">Search request</a>
like image 5
Francis Gilbert Avatar answered Oct 18 '22 03:10

Francis Gilbert