C # TextBox disposed in question can not be read readonly

In ASP.NET TextBox controls in the front end of the property is Readonly = "True", if you have set the initial value before or after their assignment to access its Text value in the background but can not get through JS way, this problem there are three solutions.

First, the way to achieve the purpose of prohibiting the use of JS editor

For details please see my other blog post (Act III and Act four): https://www.cnblogs.com/HymanWesteros/p/12118990.html

Second, the background to the value by Request

Front-end code:

<asp:TextBox ID="TextBox1" runat="server" ReadOnly="True" ></asp:TextBox>

Background Code:

string Text = Request.Form["TextBox1"].Trim();

Third, set the ReadOnly property in the background

In general, the control to set the properties in the initial page the Page_Load () method, consistent with the front end of the effect, but can also read the data in the background.

Front-end code:

<asp:TextBox ID="TextBox1" runat="server" ></asp:TextBox>

Background Code:

TextBox1.Attributes.Add("readonly","true");
 

Guess you like

Origin www.cnblogs.com/HymanWesteros/p/12131403.html