The validation of a TextBox control may fail when you use a client-side script to update the value of the TextBox control in an ASP.NET 2.0 Web application (917733)
The information in this article applies to:
SYMPTOMSWhen you try to update the value of a TextBox control in a Microsoft ASP.NET 2.0 Web application, the validation of the TextBox control may fail. This problem occurs when the following
conditions are true:
- The ReadOnly attribute of the TextBox control is set to true in the control declaration.
- You use a client-side script to update the value of the TextBox control.
CAUSEThis problem occurs because ASP.NET 2.0 prevents the client
computer from changing the value of a TextBox control when the ReadOnly attribute is set to true in the control declaration.WORKAROUNDTo work around this problem, follow these steps:
- Delete the ReadOnly attribute from the control declaration. Alternatively, set the ReadOnly attribute to false.
- Programmatically set the ReadOnly attribute to true. For Microsoft Visual C#, use the following code example.
protected void Page_Load(object sender, EventArgs e)
{
this.TextBox1.ReadOnly = true;
} For Microsoft Visual Basic .NET, use the following code example. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
TextBox1.ReadOnly = true
End Sub
REFERENCESFor more information about how to use the TextBox control, visit the following Microsoft Developer Network (MSDN)
Web site:
For
more information about how to use the ReadOnly attribute of the TextBox control, visit the following MSDN Web site:
Modification Type: | Major | Last Reviewed: | 7/14/2006 |
---|
Keywords: | kbWebForms kbValidation kbScript kbASP kbinfo kbtshoot kbprb KB917733 kbAudDeveloper |
---|
|