I've been stuck for the last two hours and need help. I've tried every single example I could find online and none of them work. I'm building a web page in ASP.NET
and want to make a list of buttons. Doesn't seem too hard right? It's been causing me issues though.
This is my code:
<ul>
<form id="tagloop" runat="server">
<% foreach (string i in data)%>
<%Response.Write("<li><button runat=\"server\" type=\"submit\" onserverclick=\"ClickTag\">" + i + "</button></li>");%>
</form>
</ul>
If I remove the Response.Write()
it only loops once but the one button it does generate actually works and calls the method on click. Also, the variable i doesn't apply.
<ul>
<form id="tagloop" runat="server">
<% foreach (string i in data)%>
<li><button runat="server" type="submit" onserverclick="ClickTag"> i </button></li>
</form>
</ul>
Is there anyway I can get it to loop, have the text of i in data, and also call the correct function on click? I haven't been able to find a balance of all three yet and any help will be appreciated.