我遇到了为aspx for
中的文本框提供id的问题继承我的代码
<%for (int i = 2; i <= 10; i++)%>
<% {%>
<div id="divPerson<%= i %>">
<label for="txtFirstNameFriend<%= i %>">Friends First Name</label>
<asp:TextBox ID="txtFirstNameFriend<%= i %>" MaxLength="50" runat="server"></asp:TextBox>
<br />
<span id="ValFirstNameFriend<%= i %>" class="ValidationError" style="color:Red" visible="false" runat="server"><p>Please enter your First Name</p></span>
<label for="txtLastNameFriend<%=i %>">Friends Last Name</label>
<br />
<label for="txtEmailAddressFriend<%= i %>">Friends Email Address</label>
<asp:TextBox ID="txtEmailAddressFriend<%= i %>" MaxLength="255" runat="server"></asp:TextBox>
<div style="display:none"><asp:TextBox ID="ValFriend<%=i %>" CssClass="ValFriend<%= i %>" MaxLength="255" runat="server"></asp:TextBox></div>
<br />
</div>
<% } %>
有没有办法在aspx文件中创建的文本框中添加动态ID?
答案 0 :(得分:4)