Solve. NET setting is read-only, hidden after background get no value problem

Source: Internet
Author: User

On the foreground page, put a few textbox, with Readonly=true set not editable, with visible= "False" setting is not visible

When you assign a value to a textbox in jquery, you don't get the value that is filled in the textbox in the background page

Here's how to fix it:

Hide with style= "Display:none" settings

There are several ways to solve a read-only problem:

1, do not set ReadOnly, set Onfocus=this.blur ()

<asp:textbox id="TextBox1" runat="server" onfocus=  this. blur () ></asp:TextBox> <asp:textbox id="TextBox1" runat= "  server" onfocus=this. blur () ></asp:TextBox>

The text box is not dimmed, but you cannot modify the content manually, and you can use the Text property to assign values in the background

2. After setting the ReadOnly property, the value can be obtained by request:

 <asp:textbox id= textbox1  Span style= "color: #800000;" > " Runat="  server   " Readonly="  true   " ></asp:TextBox> <asp:textbox id="  textbox1   runat="  server   readonly="  true   ></asp:textbox> 
string Text = request.form["TextBox1"string text = request.form[" TextBox1 "]. Trim ();

3. Set the read-only property of the text box at Page_Load ()

protected void Page_Load (object  sender, EventArgs e)  {      if (!  Page.IsPostBack)      {          TextBox1.Attributes.Add ("readonly","  true");      }  }

Solve. NET setting is read-only, hidden after background get no value problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.