passing parameters to hyperlink control

L

Lan H. Nguyen

I have this line of code in my .aspx page

<asp:HyperLink ID="hrefView" CssClass="main" ForeColor="blue" Runat="server"
NavigateUrl='<%# "View.aspx?id=" + ID.ToString()%>'>View
Customer</asp:HyperLink>

But when the page runs it shows text only "View Customer" without hyperlink.
This is what it was rendered in the page source <a id="hrefView"
class="main" style="color:Blue;">View Customer</a>

Not working either when removed the ID
<asp:HyperLink ID="hrefView" CssClass="main" ForeColor="blue" Runat="server"
NavigateUrl='<%# "View.aspx?id=100"%>'>View Customer</asp:HyperLink>

Don't pass parameters to the control, then it renders correctly
<asp:HyperLink ID="hrefView" CssClass="main" ForeColor="blue" Runat="server"
NavigateUrl='View.aspx'>View Customer</asp:HyperLink>

Does anybody have any ideas what I'm doing wrong here. Any help is
appreciated.

Lan
 
Y

Yama

Hi why not perform this operation from the code-behind?

Or:

Change the following:
<asp:HyperLink ID="hrefView" CssClass="main" ForeColor="blue" Runat="server"
NavigateUrl='View.aspx?id=<%# ID.ToString()%>'>View Customer</asp:HyperLink>

Yama
 
L

Lan H. Nguyen

Thanks for the response.
Yes I can surely do this from the code behind, it's just that I am curious
of what is possibly wrong to my code.

Your other solution shows the link alright but give this on the url
View.aspx?id=<%# ID.ToString()%>
 
Y

Yama

Try <%= ID.ToString()%>

Lan H. Nguyen said:
Thanks for the response.
Yes I can surely do this from the code behind, it's just that I am curious
of what is possibly wrong to my code.

Your other solution shows the link alright but give this on the url
View.aspx?id=<%# ID.ToString()%>
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top