Textbox client JS value acquisition in the background
Requirements:The client cannot enter the value, but it can assign a value through JS and obtain the value assigned by JS on the server side.
Recently, I was using vs2005 as a project. I encountered such a problem that the content of textbox was always inaccessible. I finally found it. It turned out to be a ghost of readonly.
Readonly
Gets or sets a value to indicate whether the content of the textbox control can be changed.
Important:
When a message is sent back, the text value of the Textbox Control (whose readonly property is set to true) is sent to the server, but the server does not process the read-only text box. This prevents malicious users from changing the read-only text value. The value of the text attribute remains in the view state between sending and sending, unless it passes through the server sideCodeModify.
You can use either of the following methods to prevent client changes:
1. Use the text control of input instead;
2. Do not set readonly directly by using properties, but by using textbox1.attributes ["readonly"] = "true" in the code.
3. textbox1.attributes ["contenteditable"] = "false ";
It is equivalent to readonly = "true" or setting textbox attributes directly from the foregroundContenteditable = "false"
Source: http://blog.csdn.net/yanwu616/archive/2010/04/28/5534879.aspx