NavigateURL question

Discussion in 'ASP .Net' started by tshad, Aug 1, 2007.

  1. tshad

    tshad Guest

    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
     
    tshad, Aug 1, 2007
    #1
    1. Advertising

  2. tshad

    Guest

    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

    On 1 août, 21:13, "tshad" <> wrote:
    > 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("P­ATH_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("P­ATH_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
     
    , Aug 4, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Helixpoint

    NavigateUrl problem

    Helixpoint, Jul 22, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    374
    Helixpoint
    Jul 22, 2003
  2. Boban Dragojlovic
    Replies:
    3
    Views:
    3,068
    vMike
    Oct 29, 2003
  3. Mark Fox

    Hyperlink NavigateUrl

    Mark Fox, Nov 3, 2003, in forum: ASP .Net
    Replies:
    5
    Views:
    9,352
    Mark Fox
    Nov 4, 2003
  4. Jason Huang

    ASPNet HyperLink NavigateUrl question

    Jason Huang, Aug 17, 2007, in forum: ASP .Net
    Replies:
    6
    Views:
    779
    Mark Rae [MVP]
    Aug 20, 2007
  5. Jason Huang
    Replies:
    1
    Views:
    412
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Aug 20, 2007
Loading...

Share This Page