是否可以将font属性设置为影响所有标记,而在单个aspx页面上没有其他内容?
我的页面中有大约40个标签,看起来都是一样的,当然有不同的ID ......
<asp:Label ID="lblIDn" runat="server" Text='<%# Eval("somecolumn" ) %>' Backcolor="White" BorderColor="Gray" BorderStyle="Solid" BorderWidth="1px" Width="30" Font-Names="Arial" Font-Size="Small"></asp:Label>
我不想一个接一个地更改所有40个标签。有没有办法像使用CSS一样设置它们?
由于
答案 0 :(得分:1)
foreach (Control item in form1.Controls)
{
try {
((Label)item).BorderColor = System.Drawing.Color.Azure;
}
catch { }
}
仅更改标签。
如果您想检查所选标签,可以使用:
if( item.UniqueID == "lblIDn")