1

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 ?

2 Answers 2

3

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") %>'
Sign up to request clarification or add additional context in comments.

2 Comments

It works with the second solution. i wrote everything inside <%# %>. Thank you
@user1747659, then I should rather remove it, not to deceive others who might find this post. Thanks for response
0

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

1 Comment

While this might be the correct thing to do, you should try to provide an explanation along with your answer. Pure code sometimes is not self-explanatory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.