-1
我不明白爲什麼這不起作用。如果textbox1
和textbox2
都包含一些文本但不起作用,代碼應該啓用Button1
。我在textbox
es中鍵入了一些文本後沒有發生任何事情。 Button1
保持禁用狀態。我甚至嘗試過兩個運營商||和& &。如何在TextBox控件具有某些值時啓用按鈕控件?
這裏是我的代碼:
protected void Page_Load(object sender, EventArgs e)
{
}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
if (TextBox1.Text == string.Empty || TextBox2.Text == string.Empty)
{
Button1.Enabled = false;
}
else
{
Button1.Enabled = true;
}
}
protected void TextBox2_TextChanged(object sender, EventArgs e)
{
if (TextBox1.Text == string.Empty || TextBox2.Text== string.Empty)
{
Button1.Enabled = false;
}
else
{
Button1.Enabled = true;
}
}
上面的代碼應該使Button1
如果textbox1
和textbox
都包含一些文本,但它不工作。
你設置'的AutoPostBack = 「真」'既'TextBox1'和'TextBox2'? – ekad
@ekad我沒有。現在我已經設置了AutopostBack = true的文本框,它正在工作。非常感謝。請將它作爲答案發布,我會接受它。 – Nullbyte