![](/img/trans.png)
[英]How can I loop through html controls in ASP.NET page with No "runat=server"
[英]i want to access 'ids' of asp.net server controls in for loop.so with single line i can set value to all controls
for(int i = 1; i < 5;i++)
{
label[i].InnerText = info.books[0].title;
}
我想要這樣的東西來循環訪問5個服務器控件的ID。 LABEL1,LABEL2,.....,label5。 它是文件后面的代碼。
如果您真的想要,可以使用FindControl
for (int i = 1; i < 5; i++)
{
Label lbl = Page.FindControl("Label" + i) as Label;
lbl.Text = info.books[0].title;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.