0
我有兩個單選按鈕。如果其中一個被選中,文本框將被激活並獲取數據。 他們在更新頁面。在頁面加載中填充數據庫中的數據,然後檢查ispostback。 如果文本框在頁面加載時有文字,文字變化和一切正常,但如果它沒有文字在第一位,它保持默認文本,並不會在提交按鈕點擊更新。文本框中的文本不會更新提交按鈕單擊
String val = "0";
if (radiobutton2.Checked && textbox1.Text.Length != 0)
val = textbox1.Text;
在頁面加載
使用此代碼初始化單選按鈕:
t.ReadOnly = true;
t.BackColor = System.Drawing.Color.Gray;
而且也爲有活性的JavaScript代碼和非活動本框
function CheckedChanged(rbtnelement, txtelement) {
if (document.getElementById(rbtnelement).checked) {
document.getElementById(txtelement).readOnly = false;
document.getElementById(txtelement).style.backgroundColor = "white";
}
else {
document.getElementById(txtelement).readOnly = true;
document.getElementById(txtelement).style.backgroundColor = "grey";
}
}
if(radiobutton2.Checked) if(textbox1.Text.Length!= 0) val = textbox1.Text;你這是什麼意思? – 2014-12-06 07:26:10
我無法得到你?實際上你想達到什麼?如果你的textbox1沒有文字,那麼你想保存一個默認值?是這樣嗎? – 2014-12-06 07:28:41
有更大的代碼,我削減了大部分,但我想要保存文本框的文本,如果它有任何文本和radiobutton2檢查。我編輯我的問題 – user4002899 2014-12-06 07:51:08