Hyperlink and ResolveURL

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

  1. tshad

    tshad Guest

    I am finally getting the path to the Current Page using Page.ResolveURL.

    I am now getting "/jobSeeker/displayCompanyOverview.aspx" which is what I
    was looking for.

    But what is the syntax to add it into the HyperLink object?

    I tried:

    <asp:Hyperlink ID="test2" Text="HyperLink Test with ResolveURL"
    NavigateUrl='<%= Page.ResolveUrl("displayCompanyOverview.aspx") %>'
    runat="server"/><br>

    and this gives me:

    http://www.stw.com/applicant/<%=%20Page.ResolveUrl("displayCompanyOverview.aspx")%20%>

    I also tried <% %> and had the same problem? Do I need sometype of Eval
    syntax?

    Thanks,

    Tom
     
    tshad, Aug 2, 2007
    #1
    1. Advertising

  2. tshad

    Guest

    Tom,
    Use <%# ... %> instead of <%= %>

    cheers,
    Vince

    On Aug 1, 7:00 pm, "tshad" <> wrote:
    > I am finally getting the path to the Current Page using Page.ResolveURL.
    >
    > I am now getting "/jobSeeker/displayCompanyOverview.aspx" which is what I
    > was looking for.
    >
    > But what is the syntax to add it into the HyperLink object?
    >
    > I tried:
    >
    > <asp:Hyperlink ID="test2" Text="HyperLink Test with ResolveURL"
    > NavigateUrl='<%= Page.ResolveUrl("displayCompanyOverview.aspx") %>'
    > runat="server"/><br>
    >
    > and this gives me:
    >
    > http://www.stw.com/applicant/<%=%20Page.ResolveUrl("displayCompanyOverview.aspx")%20%>
    >
    > I also tried <% %> and had the same problem? Do I need sometype of Eval
    > syntax?
    >
    > Thanks,
    >
    > Tom
     
    , Aug 2, 2007
    #2
    1. Advertising

  3. tshad

    tshad Guest

    <> wrote in message
    news:...
    > Tom,
    > Use <%# ... %> instead of <%= %>


    I tried that here:

    <asp:Hyperlink ID="test2" Text="HyperLink Test with ResolveURL"
    NavigateUrl='<%# Page.ResolveUrl("displayCompanyOverview.aspx") %>'
    runat="server"/>

    But I am getting just plane text and it is not a link.

    Am I missing something?

    Thanks,

    Tom

    >
    > cheers,
    > Vince
    >
    > On Aug 1, 7:00 pm, "tshad" <> wrote:
    >> I am finally getting the path to the Current Page using Page.ResolveURL.
    >>
    >> I am now getting "/jobSeeker/displayCompanyOverview.aspx" which is what I
    >> was looking for.
    >>
    >> But what is the syntax to add it into the HyperLink object?
    >>
    >> I tried:
    >>
    >> <asp:Hyperlink ID="test2" Text="HyperLink Test with ResolveURL"
    >> NavigateUrl='<%= Page.ResolveUrl("displayCompanyOverview.aspx") %>'
    >> runat="server"/><br>
    >>
    >> and this gives me:
    >>
    >> http://www.stw.com/applicant/<%=%20Page.ResolveUrl("displayCompanyOverview.aspx")%20%>
    >>
    >> I also tried <% %> and had the same problem? Do I need sometype of Eval
    >> syntax?
    >>
    >> Thanks,
    >>
    >> Tom

    >
    >
     
    tshad, Aug 2, 2007
    #3
  4. tshad

    tshad Guest

    I can set the NavigateURL for my Hyperlinks programmatically. For example,
    I can do the following in the Page_Load event and it works fine:

    test3.NavigateURL = Page.ResolveUrl("displayCompanyOverview.aspx")

    This sets it fine.

    But then for all my pages I will have to either set this for all the
    Hyperlinks and HyperlinkColumns in my DataGrid. The former would have to be
    set in Page_Load event and the later (datagrids) would have to be set in the
    PreRender event (I think). What I was hoping to do was do it in the tag
    itself.

    Thanks,

    Tom

    "tshad" <> wrote in message
    news:%...
    > <> wrote in message
    > news:...
    >> Tom,
    >> Use <%# ... %> instead of <%= %>

    >
    > I tried that here:
    >
    > <asp:Hyperlink ID="test2" Text="HyperLink Test with ResolveURL"
    > NavigateUrl='<%# Page.ResolveUrl("displayCompanyOverview.aspx") %>'
    > runat="server"/>
    >
    > But I am getting just plane text and it is not a link.
    >
    > Am I missing something?
    >
    > Thanks,
    >
    > Tom
    >
    >>
    >> cheers,
    >> Vince
    >>
    >> On Aug 1, 7:00 pm, "tshad" <> wrote:
    >>> I am finally getting the path to the Current Page using Page.ResolveURL.
    >>>
    >>> I am now getting "/jobSeeker/displayCompanyOverview.aspx" which is what
    >>> I
    >>> was looking for.
    >>>
    >>> But what is the syntax to add it into the HyperLink object?
    >>>
    >>> I tried:
    >>>
    >>> <asp:Hyperlink ID="test2" Text="HyperLink Test with ResolveURL"
    >>> NavigateUrl='<%= Page.ResolveUrl("displayCompanyOverview.aspx") %>'
    >>> runat="server"/><br>
    >>>
    >>> and this gives me:
    >>>
    >>> http://www.stw.com/applicant/<%=%20Page.ResolveUrl("displayCompanyOverview.aspx")%20%>
    >>>
    >>> I also tried <% %> and had the same problem? Do I need sometype of Eval
    >>> syntax?
    >>>
    >>> Thanks,
    >>>
    >>> Tom

    >>
    >>

    >
    >
     
    tshad, Aug 2, 2007
    #4
  5. tshad

    Guest

    Did you realize you need to call DataBind() for thge Page or the
    control in question for databinding expressions <%# %> to be
    evaluated?

    Teemu

    On 2 elo, 04:27, "tshad" <> wrote:
    > <> wrote in message
    >
    > news:...
    >
    > > Tom,
    > > Use <%# ... %> instead of <%= %>

    >
    > I tried that here:
    >
    > <asp:Hyperlink ID="test2" Text="HyperLink Test with ResolveURL"
    > NavigateUrl='<%# Page.ResolveUrl("displayCompanyOverview.aspx") %>'
    > runat="server"/>
    >
    > But I am getting just plane text and it is not a link.
    >
    > Am I missing something?
    >
    > Thanks,
    >
    > Tom
    >
    >
    >
    >
    >
    > > cheers,
    > > Vince

    >
    > > On Aug 1, 7:00 pm, "tshad" <> wrote:
    > >> I am finally getting the path to the Current Page using Page.ResolveURL.

    >
    > >> I am now getting "/jobSeeker/displayCompanyOverview.aspx" which is what I
    > >> was looking for.

    >
    > >> But what is the syntax to add it into the HyperLink object?

    >
    > >> I tried:

    >
    > >> <asp:Hyperlink ID="test2" Text="HyperLink Test with ResolveURL"
    > >> NavigateUrl='<%= Page.ResolveUrl("displayCompanyOverview.aspx") %>'
    > >> runat="server"/><br>

    >
    > >> and this gives me:

    >
    > >>http://www.stw.com/applicant/<%=%20Page.ResolveUrl("displayCompanyOverview.aspx")%20%>

    >
    > >> I also tried <% %> and had the same problem? Do I need sometype of Eval
    > >> syntax?

    >
    > >> Thanks,

    >
    > >> Tom- Piilota siteerattu teksti -

    >
    > - Näytä siteerattu teksti -
     
    , Aug 2, 2007
    #5
  6. tshad

    tshad Guest

    <> wrote in message
    news:...
    Did you realize you need to call DataBind() for thge Page or the
    control in question for databinding expressions <%# %> to be
    evaluated?

    I was pretty sure of that and that was why I also tried <%= and <% neither
    of which worked.

    Is it possible you can't do this particular function inline?

    Thanks,

    Tom

    Teemu

    On 2 elo, 04:27, "tshad" <> wrote:
    > <> wrote in message
    >
    > news:...
    >
    > > Tom,
    > > Use <%# ... %> instead of <%= %>

    >
    > I tried that here:
    >
    > <asp:Hyperlink ID="test2" Text="HyperLink Test with ResolveURL"
    > NavigateUrl='<%# Page.ResolveUrl("displayCompanyOverview.aspx") %>'
    > runat="server"/>
    >
    > But I am getting just plane text and it is not a link.
    >
    > Am I missing something?
    >
    > Thanks,
    >
    > Tom
    >
    >
    >
    >
    >
    > > cheers,
    > > Vince

    >
    > > On Aug 1, 7:00 pm, "tshad" <> wrote:
    > >> I am finally getting the path to the Current Page using
    > >> Page.ResolveURL.

    >
    > >> I am now getting "/jobSeeker/displayCompanyOverview.aspx" which is what
    > >> I
    > >> was looking for.

    >
    > >> But what is the syntax to add it into the HyperLink object?

    >
    > >> I tried:

    >
    > >> <asp:Hyperlink ID="test2" Text="HyperLink Test with ResolveURL"
    > >> NavigateUrl='<%= Page.ResolveUrl("displayCompanyOverview.aspx") %>'
    > >> runat="server"/><br>

    >
    > >> and this gives me:

    >
    > >>http://www.stw.com/applicant/<%=%20Page.ResolveUrl("displayCompanyOverview.aspx")%20%>

    >
    > >> I also tried <% %> and had the same problem? Do I need sometype of
    > >> Eval
    > >> syntax?

    >
    > >> Thanks,

    >
    > >> Tom- Piilota siteerattu teksti -

    >
    > - Näytä siteerattu teksti -
     
    tshad, Aug 2, 2007
    #6
  7. tshad

    tshad Guest

    I assume this can't be done.

    I was told by some else:

    "What you'll need to do then is to use the '<%# %>' data-binding expression
    instead, and call Page.DataBind from the code-behind. But if you don't have
    code-behind, then I don't believe you can accomplish what you want."

    Since I am not using code-behind I assume this can't be done. I have tried
    all kinds of combinations and can't get it to work, so I give up as it is
    causing too much time.

    Thanks,

    Tom

    "tshad" <> wrote in message
    news:Ob%...
    >
    > <> wrote in message
    > news:...
    > Did you realize you need to call DataBind() for thge Page or the
    > control in question for databinding expressions <%# %> to be
    > evaluated?
    >
    > I was pretty sure of that and that was why I also tried <%= and <% neither
    > of which worked.
    >
    > Is it possible you can't do this particular function inline?
    >
    > Thanks,
    >
    > Tom
    >
    > Teemu
    >
    > On 2 elo, 04:27, "tshad" <> wrote:
    >> <> wrote in message
    >>
    >> news:...
    >>
    >> > Tom,
    >> > Use <%# ... %> instead of <%= %>

    >>
    >> I tried that here:
    >>
    >> <asp:Hyperlink ID="test2" Text="HyperLink Test with ResolveURL"
    >> NavigateUrl='<%# Page.ResolveUrl("displayCompanyOverview.aspx") %>'
    >> runat="server"/>
    >>
    >> But I am getting just plane text and it is not a link.
    >>
    >> Am I missing something?
    >>
    >> Thanks,
    >>
    >> Tom
    >>
    >>
    >>
    >>
    >>
    >> > cheers,
    >> > Vince

    >>
    >> > On Aug 1, 7:00 pm, "tshad" <> wrote:
    >> >> I am finally getting the path to the Current Page using
    >> >> Page.ResolveURL.

    >>
    >> >> I am now getting "/jobSeeker/displayCompanyOverview.aspx" which is
    >> >> what I
    >> >> was looking for.

    >>
    >> >> But what is the syntax to add it into the HyperLink object?

    >>
    >> >> I tried:

    >>
    >> >> <asp:Hyperlink ID="test2" Text="HyperLink Test with ResolveURL"
    >> >> NavigateUrl='<%= Page.ResolveUrl("displayCompanyOverview.aspx") %>'
    >> >> runat="server"/><br>

    >>
    >> >> and this gives me:

    >>
    >> >>http://www.stw.com/applicant/<%=%20Page.ResolveUrl("displayCompanyOverview.aspx")%20%>

    >>
    >> >> I also tried <% %> and had the same problem? Do I need sometype of
    >> >> Eval
    >> >> syntax?

    >>
    >> >> Thanks,

    >>
    >> >> Tom- Piilota siteerattu teksti -

    >>
    >> - Näytä siteerattu teksti -

    >
    >
    >
     
    tshad, Aug 3, 2007
    #7
  8. tshad

    tshad Guest

    I decided to try one more time to use the HyperLink in my Datagrid using <%#
    %> and eval and unlike a Hyperlink which outside of the datagrid gives me
    nothing, this does resolve the path but doesn't do it the same as when you
    do it programmatically.

    If I do:

    dim test as String
    test = Page.ResolveUrl("displayCompanyOverview.aspx")
    test3.NavigateURL = Page.ResolveUrl("displayCompanyOverview.aspx")

    This works fine and gives you the URL:

    /jobseeker/displayCompanyOverview.aspx (the Current Page Path)

    If I do:

    <asp:HyperLinkColumn ItemStyle-Width="190" DataTextField="JobTitle"
    DataTextFormatString="{0}" DataNavigateUrlField="PositionID"
    DataNavigateUrlFormatString='<%#
    Page.ResolveURL("displayPositionNS.aspx?PositionID=" + eval("{0}"))'

    This gives me:

    /applicant/displayPositionNS.aspx?PositionID=210 (The Controls Path

    I have no idea why this is working this way. It makes no sense to me.

    It doesn't appear to be using the ResolveURL at all. If it did, it would
    resolve to the same path as when it was done programatically.

    Tom

    "tshad" <> wrote in message
    news:%23mzg$...
    >I assume this can't be done.
    >
    > I was told by some else:
    >
    > "What you'll need to do then is to use the '<%# %>' data-binding
    > expression instead, and call Page.DataBind from the code-behind. But if
    > you don't have code-behind, then I don't believe you can accomplish what
    > you want."
    >
    > Since I am not using code-behind I assume this can't be done. I have
    > tried all kinds of combinations and can't get it to work, so I give up as
    > it is causing too much time.
    >
    > Thanks,
    >
    > Tom
    >
    > "tshad" <> wrote in message
    > news:Ob%...
    >>
    >> <> wrote in message
    >> news:...
    >> Did you realize you need to call DataBind() for thge Page or the
    >> control in question for databinding expressions <%# %> to be
    >> evaluated?
    >>
    >> I was pretty sure of that and that was why I also tried <%= and <%
    >> neither of which worked.
    >>
    >> Is it possible you can't do this particular function inline?
    >>
    >> Thanks,
    >>
    >> Tom
    >>
    >> Teemu
    >>
    >> On 2 elo, 04:27, "tshad" <> wrote:
    >>> <> wrote in message
    >>>
    >>> news:...
    >>>
    >>> > Tom,
    >>> > Use <%# ... %> instead of <%= %>
    >>>
    >>> I tried that here:
    >>>
    >>> <asp:Hyperlink ID="test2" Text="HyperLink Test with ResolveURL"
    >>> NavigateUrl='<%# Page.ResolveUrl("displayCompanyOverview.aspx") %>'
    >>> runat="server"/>
    >>>
    >>> But I am getting just plane text and it is not a link.
    >>>
    >>> Am I missing something?
    >>>
    >>> Thanks,
    >>>
    >>> Tom
    >>>
    >>>
    >>>
    >>>
    >>>
    >>> > cheers,
    >>> > Vince
    >>>
    >>> > On Aug 1, 7:00 pm, "tshad" <> wrote:
    >>> >> I am finally getting the path to the Current Page using
    >>> >> Page.ResolveURL.
    >>>
    >>> >> I am now getting "/jobSeeker/displayCompanyOverview.aspx" which is
    >>> >> what I
    >>> >> was looking for.
    >>>
    >>> >> But what is the syntax to add it into the HyperLink object?
    >>>
    >>> >> I tried:
    >>>
    >>> >> <asp:Hyperlink ID="test2" Text="HyperLink Test with ResolveURL"
    >>> >> NavigateUrl='<%= Page.ResolveUrl("displayCompanyOverview.aspx") %>'
    >>> >> runat="server"/><br>
    >>>
    >>> >> and this gives me:
    >>>
    >>> >>http://www.stw.com/applicant/<%=%20Page.ResolveUrl("displayCompanyOverview.aspx")%20%>
    >>>
    >>> >> I also tried <% %> and had the same problem? Do I need sometype of
    >>> >> Eval
    >>> >> syntax?
    >>>
    >>> >> Thanks,
    >>>
    >>> >> Tom- Piilota siteerattu teksti -
    >>>
    >>> - Näytä siteerattu teksti -

    >>
    >>
    >>

    >
    >
     
    tshad, Aug 3, 2007
    #8
    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. Lloyd Sheen

    More woes ResolveUrl

    Lloyd Sheen, Jan 24, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    834
    Natty Gur
    Jan 26, 2004
  2. Lloyd Dupont

    ResolveUrl in a static helper method

    Lloyd Dupont, Jan 11, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    15,751
    Sirko
    Oct 31, 2007
  3. Lloyd Dupont

    alternative to ResolveUrl()

    Lloyd Dupont, Jan 29, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    608
    Lloyd Dupont
    Jan 29, 2006
  4. SandyIsCool
    Replies:
    4
    Views:
    572
    Edwin Knoppert
    Dec 15, 2006
  5. NightOwl888
    Replies:
    1
    Views:
    937
    David Wier
    Aug 21, 2007
Loading...

Share This Page