【发布时间】:2015-02-15 22:55:59
【问题描述】:
当点击空的 asp:textbox 时,我想立即将 asp:label 的可见性设置为 false 我将一些标签设置为验证检查 当文本框为空时,标签变为可见,但当文本更改或单击文本框进行编辑时,它不是不可见的 请帮帮我
代码:
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox1.Text == "")
Label1.Visible = true;
}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
Label1.Visible = false;
}
【问题讨论】:
-
你自己试过什么?
-
protected void Button1_Click(object sender, EventArgs e) { if (TextBox1.Text == "") Label1.Visible = true; } protected void TextBox1_TextChanged(object sender, EventArgs e) { Label1.Visible = false; }
-
显示您的代码到目前为止您尝试过的内容
-
在你的文本框上使用 jquery focus() 事件并在客户端顺利完成所有事情会更好吗?
-
使用回发来处理这是一个非常糟糕的主意。而是使用简单的 javascript 来避免往返服务器。
标签: c# asp.net textbox textchanged