我試圖通過單擊單選按鈕來更改我的文本框的值。但是當我點擊那個單選按鈕時,沒有任何反應!有人知道爲什麼嗎?這裏是代碼:當我單擊ASP.NET中的單選按鈕時,爲什麼我的文本框的值不會更改?
protected void rbOpgelost_CheckedChanged(object sender, EventArgs e)
{
tbEinddatum.Text = DateTime.Now.ToString();
}
我試圖通過單擊單選按鈕來更改我的文本框的值。但是當我點擊那個單選按鈕時,沒有任何反應!有人知道爲什麼嗎?這裏是代碼:當我單擊ASP.NET中的單選按鈕時,爲什麼我的文本框的值不會更改?
protected void rbOpgelost_CheckedChanged(object sender, EventArgs e)
{
tbEinddatum.Text = DateTime.Now.ToString();
}
您是否已將單選按鈕的Autopostback
屬性設置爲true
?
單選按鈕上的AutoPostback設置爲true?
此外當你說「點擊那個單選按鈕」時,你點擊一個已經被選中的單選按鈕,因爲這不會觸發checkchanged事件。
不,它還沒有被檢查。爲什麼我應該將AutoPostback設置爲true? – SamekaTV 2011-02-15 10:37:29
您是否使用ASP.Net控件?如果是這樣,您可以啓用AutoPostback來實現這種效果。如果您使用的是標準HTML,或者您不想啓用AutoPostback,那麼您需要其他一些機制來激活更改,例如表單提交。
我正在使用asp.net控件,但是沒錯。我必須將AutoPostback設置爲true。非常感謝你!!! – SamekaTV 2011-02-15 10:38:23
AutoPostback must be set to true since you are assigining text to the textbox control from the codebehind in the **rbOpgelost_CheckedChanged** property of the radio button whcich is executed on the serverside.
If autopostback is not set to true the checkedchanged event wil not be fired until a post back occurs.
非常感謝。我沒有改變它是真的。 – SamekaTV 2011-02-15 10:39:25