Test an ASP. for a net2.0 page, a textbox needs to control the user input format and change the content in script mode. To prevent the user from directly inputting the content, the readonly attribute of the textbox is set to true.
As a result, no matter how the client script changes the textbox value, the text attribute on the server remains the same as the initial value, because the debugging was coming off work yesterday, it was a bit confusing. This morning, I suddenly thought it might be related to this readonly attribute. Because it is a server attribute, the result is normal after this attribute is removed. Since the Server property and client property have different roles, you cannot directly set them in the control property, so you can only useAttributes ["readonly"] = "true"This must be set only for the readonly client. After testing, the read-only effect of preventing direct input by the client is achieved.
After comparison, we found that the client code generated by the two methods uses the readonly client attribute of the HTML Tag. The difference is that the value generated by the server attribute is different from that generated by the client attribute, when the Server property is set to true, the client changes to"Readonly = "readonly"", And the client property changes to"Readonly = "true"".
Therefore, if you want to set the textbox client to read-only, you must use"Attributes ["readonly"] = "true"You cannot directly modify the server control attributes.