-
一个点击下拉框可以选择文本框颜色的案例
作者: 许泽博 发布: 2019/1/25 分类: 网站 阅读: 次 查看评论
-
这段时间在做一个小项目,过程有一个选择下拉框同时可以将文本框背景设定为指定颜色的需求,经过百度多次寻找,最终在csdn论坛找到一个案例,最终在项目实现想要功能,下面是我的具体实例:
具体代码如下:
网页前台:
<
body
>
<
form
runat
=
"server"
>
CausesValidation="True" Height="16px" TextMode="MultiLine" Width="420px"></asp:TextBox></
form
>
</
body
>
网页后台:
protected void DropDownList5_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList5.SelectedValue == "红")
{
TextBox1.Attributes["style"] = "background-color:Red";
// TextBox1.Attributes["style"] = "BackColor:Red";
}
else if (DropDownList5.SelectedValue == "黄")
{
TextBox1.Attributes["style"] = "background-color:Yellow";
}
else if (DropDownList5.SelectedValue == "绿")
{
TextBox1.Attributes["style"] = "background-color:Lime";
}
else
{
TextBox1.Attributes["style"] = "background-color:blue";
}
}原创文章,转载请注明出处!标签: Visual Studio
评论列表: