我想多次更改 asp 标签。
这是asp.net代码
<asp:Label ID="lbl_Text1" runat="server" Text="">
<asp:Label ID="lbl_Text2" runat="server" Text="">
<asp:Label ID="lbl_Text3" runat="server" Text="">
<asp:Label ID="lbl_Text4" runat="server" Text="">
而不是使用这个:
C# 代码
lbl_Text1.Text = "hello";
lbl_Text2.Text = "hello";
lbl_Text3.Text = "hello";
lbl_Text4.Text = "hello";
我尝试使用 for 循环
for (int i = 1; i <= 4; i++)
{
lbl_Text[i].Text = "hello";
}
我得到这个错误......
无法将 [] 索引应用于“system.web.ui.webcontrols.label”类型的表达式
有没有人可以帮助我?