Thursday, September 16, 2010

Get readonly textbox value from C# (codebehind file)

If textbox is in readonly mode, then we wont be get value in c# file. For that we have to do some workaround as below.

1) Create Textbox -> Textbox id = txtReadonly.
2) No need to assign Readonly = true in aspx file.
3) In server side i mean in c# file assign readonly property to textbox as below.

if (!IsPostBack)
{
txtReadonly.Attributes.Add("readonly", "readonly");
}

Now you will get the value from the textbox.

No comments: