TextBox value and Javascript

H

Hardy Wang

Guys,
I have a web form with some <Asp:TextBox> controls, on some condition, I
need to trigger a client side JavaScript to clean all values of these boxes,
like below:

function DisableForm() {
document.getElementById("UserCtrl_Text_97").value = "";
document.getElementById("UserCtrl_Text_97").disabled = true;

document.getElementById("UserCtrl_Text_98").value = "";
document.getElementById("UserCtrl_Text_98").disabled = true;

document.getElementById("UserCtrl_Text_99").value = "";
document.getElementById("UserCtrl_Text_99").disabled = true;

document.getElementById("UserCtrl_Text_100").value = "";
document.getElementById("UserCtrl_Text_100").disabled = true;
}

The problem is, when I click "Save" button, all original data with these
text boxes are posted to server, instead of empty values.

Anybody knows why?
 
W

William F. Robertson, Jr.

When you disable a control, its values are not posted back. So the control
is pulling its previous value from viewstate.

HTH,

bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top