Reputation: 11
I am trying to send an ASIN number into the querystring from a hyperlink and I'm having trouble getting the correct syntax. Any ideas?
<asp:HyperLink ID="hlProductPage" Enabled="true" runat="server" NavigateUrl="ProductPage.aspx?ASIN=<%# Eval("ASIN")%>">Read More...</asp:HyperLink>
Thanks so much!
Upvotes: 1
Views: 1341
Reputation: 28618
NavigateUrl='<%# Eval("ASIN", "ProductPage.aspx?ASIN={0}")%>'
When you use <% %>
in attributes of server/user controls <%
must appear just after the opening quote and %>
must appear just before the closing quote. In other words, you cannot have both code and static content. Also, use single quotes, that way you can use double quotes for strings without confusing the parser.
Upvotes: 7
Reputation: 115
try
NavigateUrl='ProductPage.aspx?ASIN=<%# Eval("ASIN")%>'>
notice the single quotes
Upvotes: 1
Reputation: 16031
You'll need to set the NavigateURL property in the code behind.
Upvotes: -1