[RESOLVED] HTML Encoding in an asp:LinkButton

Hey All

I am trying to use HTML Encoding in an asp:LinkButton, but it is not working for me. Here is my code:

<% foreach (var id in item.DataID)
	 { %>
		<asp:LinkButton runat="server" ID="DailyUnitValueHyperLink"
					Text="Daily Trends"
					onclick="DailyUnitValueHyperLink_Click"
					CommandArgument="<%: id %>"></asp:LinkButton>
   <% } %>


I am getting the DataId from list of string on my page Model. I am then trying to place that ID into the CommandArgument of the LinkButton. But it is not working.

I have tried both of these and neither work:

I don't think a code block like this can work.   You're trying to create multiple LinkButtons, all with the same ID, and ID's are required to be unique.

I suggest using a Repeater to handle this.

http://www.w3schools.com/ASPNET/aspnet_repeater.asp 

thoughts on "[RESOLVED] HTML Encoding in an asp:LinkButton"

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>