newbie question on hyperlinks

Discussion in 'ASP .Net' started by Neil, Feb 19, 2007.

  1. Neil

    Neil Guest

    Hi I have this page which has a dynamically loaded product list. I need to
    allow users to click on an item in the list and theis load up the next page
    according to what they've clicked.

    In asp I would just have a link such as range.asp?ID=<%code for RangeID%>

    In asp.net (2.0) I have
    <asp:HyperLink id="HyperLink1" runat="server" Text='<%# Eval("sName") %>'
    NavigateUrl='<%# Eval("sRootLink") %>'
    __designer:wfdid="w29"></asp:HyperLink>


    With sRootLink set to 'range.aspx?ID=1' etc simply because I don't know how
    to code this.

    What I want is NavigateUrl='range.aspx?ID=' & '<%# Eval("sRootLink") %>' or
    something like it, but this always fails!

    Any advice appreciated.

    cheers,

    NEIL
    Neil, Feb 19, 2007
    #1
    1. Advertising

  2. You don't need to care about the id. Likely, your hyperlink is located
    somewhere in a databound control like repeater, datalist or gridview. It is
    enough to write just id="myId" and asp.net will generate unique client-side
    ids. In some scenarios you need to operate with client ids, but for most
    server-side tasks myId will be just enough.

    --
    Eliyahu Goldin,
    Software Developer & Consultant
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin
    http://usableasp.net


    "Neil" <> wrote in message
    news:erca72$agb$1$...
    > Hi I have this page which has a dynamically loaded product list. I need to
    > allow users to click on an item in the list and theis load up the next
    > page according to what they've clicked.
    >
    > In asp I would just have a link such as range.asp?ID=<%code for RangeID%>
    >
    > In asp.net (2.0) I have
    > <asp:HyperLink id="HyperLink1" runat="server" Text='<%# Eval("sName") %>'
    > NavigateUrl='<%# Eval("sRootLink") %>'
    > __designer:wfdid="w29"></asp:HyperLink>
    >
    >
    > With sRootLink set to 'range.aspx?ID=1' etc simply because I don't know
    > how to code this.
    >
    > What I want is NavigateUrl='range.aspx?ID=' & '<%# Eval("sRootLink") %>'
    > or something like it, but this always fails!
    >
    > Any advice appreciated.
    >
    > cheers,
    >
    > NEIL
    >
    Eliyahu Goldin, Feb 19, 2007
    #2
    1. Advertising

  3. Neil

    Neil Guest

    Hi Eliyahu,

    I appreciate you help, but I'm afraid I need more assistance - I'm really
    new to asp.net and finding it quite difficult.

    I;m not sure where i should put what you've suggested.

    Here's the code that I'm struggling with:

    <h1>Treatment Range</h1>

    <div id="RangeNav">

    <asp:datalist id="DataList2" runat="server"
    datasourceid="SqlDataSource2"><ItemTemplate>

    <asp:HyperLink id="HyperLink2" runat="server" Text='<%# Eval("sName") %>'
    NavigateUrl='<%# Eval("sRootLink") %>'
    __designer:wfdid="w34"></asp:HyperLink>

    </ItemTemplate>

    </asp:datalist>

    </div>

    Where do I put your bit to make this happen?

    Cheers,
    NEIL



    "Eliyahu Goldin" <> wrote in
    message news:%...
    > You don't need to care about the id. Likely, your hyperlink is located
    > somewhere in a databound control like repeater, datalist or gridview. It
    > is enough to write just id="myId" and asp.net will generate unique
    > client-side ids. In some scenarios you need to operate with client ids,
    > but for most server-side tasks myId will be just enough.
    >
    > --
    > Eliyahu Goldin,
    > Software Developer & Consultant
    > Microsoft MVP [ASP.NET]
    > http://msmvps.com/blogs/egoldin
    > http://usableasp.net
    >
    >
    > "Neil" <> wrote in message
    > news:erca72$agb$1$...
    >> Hi I have this page which has a dynamically loaded product list. I need
    >> to allow users to click on an item in the list and theis load up the next
    >> page according to what they've clicked.
    >>
    >> In asp I would just have a link such as range.asp?ID=<%code for RangeID%>
    >>
    >> In asp.net (2.0) I have
    >> <asp:HyperLink id="HyperLink1" runat="server" Text='<%# Eval("sName") %>'
    >> NavigateUrl='<%# Eval("sRootLink") %>'
    >> __designer:wfdid="w29"></asp:HyperLink>
    >>
    >>
    >> With sRootLink set to 'range.aspx?ID=1' etc simply because I don't know
    >> how to code this.
    >>
    >> What I want is NavigateUrl='range.aspx?ID=' & '<%# Eval("sRootLink") %>'
    >> or something like it, but this always fails!
    >>
    >> Any advice appreciated.
    >>
    >> cheers,
    >>
    >> NEIL
    >>

    >
    >
    Neil, Feb 19, 2007
    #3
  4. id="HyperLink2" that you already have is just fine, no need to put anything
    else.

    --
    Eliyahu Goldin,
    Software Developer & Consultant
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin


    "Neil" <> wrote in message
    news:ercqi6$21s$1$...
    > Hi Eliyahu,
    >
    > I appreciate you help, but I'm afraid I need more assistance - I'm really
    > new to asp.net and finding it quite difficult.
    >
    > I;m not sure where i should put what you've suggested.
    >
    > Here's the code that I'm struggling with:
    >
    > <h1>Treatment Range</h1>
    >
    > <div id="RangeNav">
    >
    > <asp:datalist id="DataList2" runat="server"
    > datasourceid="SqlDataSource2"><ItemTemplate>
    >
    > <asp:HyperLink id="HyperLink2" runat="server" Text='<%# Eval("sName") %>'
    > NavigateUrl='<%# Eval("sRootLink") %>'
    > __designer:wfdid="w34"></asp:HyperLink>
    >
    > </ItemTemplate>
    >
    > </asp:datalist>
    >
    > </div>
    >
    > Where do I put your bit to make this happen?
    >
    > Cheers,
    > NEIL
    >
    >
    >
    > "Eliyahu Goldin" <> wrote in
    > message news:%...
    > > You don't need to care about the id. Likely, your hyperlink is located
    > > somewhere in a databound control like repeater, datalist or gridview. It
    > > is enough to write just id="myId" and asp.net will generate unique
    > > client-side ids. In some scenarios you need to operate with client ids,
    > > but for most server-side tasks myId will be just enough.
    > >
    > > --
    > > Eliyahu Goldin,
    > > Software Developer & Consultant
    > > Microsoft MVP [ASP.NET]
    > > http://msmvps.com/blogs/egoldin
    > > http://usableasp.net
    > >
    > >
    > > "Neil" <> wrote in message
    > > news:erca72$agb$1$...
    > >> Hi I have this page which has a dynamically loaded product list. I need
    > >> to allow users to click on an item in the list and theis load up the

    next
    > >> page according to what they've clicked.
    > >>
    > >> In asp I would just have a link such as range.asp?ID=<%code for

    RangeID%>
    > >>
    > >> In asp.net (2.0) I have
    > >> <asp:HyperLink id="HyperLink1" runat="server" Text='<%# Eval("sName")

    %>'
    > >> NavigateUrl='<%# Eval("sRootLink") %>'
    > >> __designer:wfdid="w29"></asp:HyperLink>
    > >>
    > >>
    > >> With sRootLink set to 'range.aspx?ID=1' etc simply because I don't know
    > >> how to code this.
    > >>
    > >> What I want is NavigateUrl='range.aspx?ID=' & '<%# Eval("sRootLink")

    %>'
    > >> or something like it, but this always fails!
    > >>
    > >> Any advice appreciated.
    > >>
    > >> cheers,
    > >>
    > >> NEIL
    > >>

    > >
    > >

    >
    >
    Eliyahu Goldin, Feb 19, 2007
    #4
  5. Hi Neil,

    It's simple:
    c# :

    <ItemTemplate>
    <asp:HyperLink id="HyperLink2" runat="server" Text='<%# Eval("sName") %>'
    NavigateUrl='<%# "range.aspx?ID=" + Eval("sRootLink") %>'
    __designer:wfdid="w34"/>
    </ItemTemplate>

    vb.net :

    <ItemTemplate>
    <asp:HyperLink id="HyperLink2" runat="server" Text='<%# Eval("sName") %>'
    NavigateUrl='<%# "range.aspx?ID=" & Eval("sRootLink") %>'
    __designer:wfdid="w34"/>
    </ItemTemplate>

    --
    Milosz


    "Neil" wrote:

    > Hi I have this page which has a dynamically loaded product list. I need to
    > allow users to click on an item in the list and theis load up the next page
    > according to what they've clicked.
    >
    > In asp I would just have a link such as range.asp?ID=<%code for RangeID%>
    >
    > In asp.net (2.0) I have
    > <asp:HyperLink id="HyperLink1" runat="server" Text='<%# Eval("sName") %>'
    > NavigateUrl='<%# Eval("sRootLink") %>'
    > __designer:wfdid="w29"></asp:HyperLink>
    >
    >
    > With sRootLink set to 'range.aspx?ID=1' etc simply because I don't know how
    > to code this.
    >
    > What I want is NavigateUrl='range.aspx?ID=' & '<%# Eval("sRootLink") %>' or
    > something like it, but this always fails!
    >
    > Any advice appreciated.
    >
    > cheers,
    >
    > NEIL
    >
    >
    >
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=, Feb 19, 2007
    #5
  6. Neil

    Neil Guest

    Excellent!

    Thank you for your assistance!

    NEIL
    Neil, Feb 20, 2007
    #6
    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. Alex
    Replies:
    2
    Views:
    530
  2. JezB
    Replies:
    6
    Views:
    3,274
    Raterus
    May 25, 2004
  3. Gene Ellis
    Replies:
    0
    Views:
    506
    Gene Ellis
    Aug 25, 2004
  4. JezB

    Add hyperlinks dynamically - newbie question

    JezB, May 24, 2004, in forum: ASP .Net Web Controls
    Replies:
    6
    Views:
    139
    Raterus
    May 25, 2004
  5. Replies:
    3
    Views:
    156
    Mike Brind
    Aug 27, 2006
Loading...

Share This Page