I wrote this code. The code contains the expected runat="server" attribute, but it is giving me this error message: error on hiddenfield
part.
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<asp:HiddenField ID="HiddenField1" Value="<%#Eval("Path")%>" runat="server" />
<img alt="image" style="text-align: center" src="<%#Eval("Path")%>" /><asp:CheckBox
ID="CheckBox1" runat="server" />
<br></br>
</ItemTemplate>
</asp:Repeater>
You could not use double quotes within double quotes so use combination of single and double quotes
.
Change
<asp:HiddenField ID="HiddenField1" Value="<%#Eval("Path")%>" runat="server" />
To
<asp:HiddenField ID="HiddenField1" Value='<%#Eval("Path")%>' runat="server" />
Try using single quotes instead of double quotes when using an eval scriptlet, like this:
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<asp:HiddenField ID="HiddenField1" Value='<%#Eval("Path")%>' runat="server" />
<img alt="image" style="text-align: center" src='<%#Eval("Path")%>' /></a><asp:CheckBox
ID="CheckBox1" runat="server" />
<br></br>
</ItemTemplate>
</asp:Repeater>
I really don't understand the reasoning why this is required, but that is what works.
You cannot have runat
inside of a html comment.
(Not the problem of this question, but it matches the title of this question)
Suppose you have an ASP control that you want to "comment out", then you might end up with a page that cannot show at all, with, if you are lucky, the "server tag is not well-formed" exception, or with a simple 404-not found status code.
Fix: change the runat e.g. like this:
<!-- asp.Label runatX="server" ... -->
I had the same error because of quotes and this is how I fixed mine
OnClientClick='<%# "CallToFunc("+ Eval("Val") +
",\"" + Eval("StringVal") + "\");return false;"'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With