I am writing a form with one value being a total of a couple other values from my page. I put this in a read-only textbox so it can't be changed, and when I change the other boxes values, the JavaScript automatically changes this value. However, when I generate the e-mail I use textboxTotalSpace.text to make it appear in my email, but this will only display the original value, and not the new one.
Does anyone know how I fix this?
Thanks.
TextBox server control will not pick up the changed values (during LoadPostData()) if the textbox is set to read only. Check this link for a fix:
http://aspadvice.com/blogs/joteke/archive/2006/04/12/16409.aspx
Hope this helps,
Vivek
Thanks Vivek, but I am unsure where I am supposed to add theTextBox1.Attributes.Add("readonly","readonly")
That should go in the Page_Load event.
protected void Page_Load(object sender, EventArgs e)
{
// add the javascript attributes
TextBox1.Attributes.Add("readonly", "readonly");
}
Thanks
Because you are changing data at client side using java script....
You can put this in the Page Load method.
suresh modiya:
Because you are changing data at client side using java script....
Changed text box value client side WILL show up in the server code behind because textbox implements IPostBackDataHandler interface and it loads its value from the forms POST data in the LoadPostBackData() method.
Its only when it is set to readonly that this data load will not work on postback, hence the alternative.
Vivek
0 comments:
Post a Comment