ASP.NET capture Client-side textbox value

letsgetsilly

Senior member
Oct 27, 2002
397
0
0
I'm running ASP.NET 2.0 web application. I have 2 text boxes, A and B. A is enabled and the B is disabled. B's value is set by the following working javascript to equal 100-A's value:

document.getElementById("B").value = 100-ValueOfA;

I'm unable to use the code behind to grab this value after a postback, and I'm curious as to why not. The textboxes are within the ASP.NET 2.0 Wizard control, which renames the clientside ID's. However, other text boxes I'm able to get the value for that are also in the wizard.

I'm also using an AJAX panel to capture postback.
 

WannaFly

Platinum Member
Jan 14, 2003
2,811
1
0
Because it's disabled, it wont submit data upon postback. You probably want to enable it and set it to readonly.
 

Jaxidian

Platinum Member
Oct 22, 2001
2,230
0
71
twitter.com
Originally posted by: WannaFly
Because it's disabled, it wont submit data upon postback. You probably want to enable it and set it to readonly.

Yup, that's precisely the case. The browser won't post data to the server if the field is disabled. Readonly, on the other hand, it will post.
 

letsgetsilly

Senior member
Oct 27, 2002
397
0
0
The read-only method did not do it. I've had to calculate the textbox value in the code behind so that it is correctly saved. I couldn't get that vaue to post back either way.