newbie question on hyperlinks

N

Neil

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
 
E

Eliyahu Goldin

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
 
N

Neil

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 said:
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 said:
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
 
E

Eliyahu Goldin

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 said:
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 said:
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 said:
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
 
G

Guest

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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top