Stefan P.
Stefan P.

Reputation: 331

Trying to pass a parameter in ASP.NET ! Parsing error

I am trying to pass a parameter from a page to another. I am getting parsing errors (Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. )

This is the code :

<a runat="server" href="~/ProductDetails.aspx?IDProduct=<%# Eval("IDProduct") %>">
   <asp:Label Font-Size="16px" ForeColor="Red" runat="server">get specifications</asp:Label>
</a>

I am getting errors at IDProduct=<%# Eval("IDProduct") %>! How should i write it ?

Upvotes: 1

Views: 124

Answers (2)

Andrei
Andrei

Reputation: 56726

The proper way to handle such cases is to make the whole attribute value generated inside <%# %>. Also note the updated quoting pattern - single quotes around attribute value, and double quotes inside <%# %>.

href='<%# "~/ProductDetails.aspx?IDProduct=" + Eval("IDProduct") %>'

Upvotes: 3

user1999284
user1999284

Reputation: 45

Try to do this <a runat="server" href="~/ProductDetails.aspx?IDProduct="<%# Eval("IDProduct") %>>

Upvotes: 0

Related Questions