NavigateURL question

  • Thread starter Thread starter tshad
  • Start date Start date
T

tshad

I need to explicitly use the path of my page and am trying to do the
following:

<asp:Hyperlink ID="test" Text="HyperLinkTest" NavigateUrl=<%#
request.ServerVariables("PATH_INFO").Substring(0,request.ServerVariables("PATH_INFO").LastIndexOf("/")+1)
& "displayCompanyOverview.aspx" %> runat="server"/><br>

This doesn't work as it only displays static text.

In my trace statement,
request.ServerVariables("PATH_INFO").Substring(0,request.ServerVariables("PATH_INFO").LastIndexOf("/")+1)
& "displayCompanyOverview.aspx" equates to
"/jobseeker/displayCompanyOverview.aspx" which looks correct?

I assume my syntax is wrong.

Do I need to do some type of "Eval" to make this work?

Thanks,

Tom
 
Hi Tom,

You cannot use the <% %> tags within server attributes, only within
"normal" attributes (eg : it's ok for "href", "src", "id" but not for
"Text", "NavigateUrl", ImageUrl"...).

Easiest way around : drop the HyperLink and use a normal link
instead :

<a id="test" href='<%=
request.ServerVariables("PATH_INFO").Substring(0,request.ServerVariables("P­
ATH_INFO").LastIndexOf("/")+1)
& "displayCompanyOverview.aspx" %>'>HyperLinkTest</a>

This should work.

Michel
 
Back
Top