asp.net怎样实现DropDownList控件控制字体大小,Button控件执行过程,label控件显示结果?
展开全部
不知道你要的效果是不是这样:
前台代码:
<div>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Value="12">12号</asp:ListItem>
<asp:ListItem Value="14">14号</asp:ListItem>
</asp:DropDownList>
</div>
<div>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
</div>
<div>
<asp:Label ID="Label1" runat="server" Text="Label">显示结果</asp:Label>
</div>
后台代码:
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Style.Add(HtmlTextWriterStyle.FontSize, DropDownList1.SelectedItem.Value+"px");
}
前台代码:
<div>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Value="12">12号</asp:ListItem>
<asp:ListItem Value="14">14号</asp:ListItem>
</asp:DropDownList>
</div>
<div>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
</div>
<div>
<asp:Label ID="Label1" runat="server" Text="Label">显示结果</asp:Label>
</div>
后台代码:
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Style.Add(HtmlTextWriterStyle.FontSize, DropDownList1.SelectedItem.Value+"px");
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询