How to make a text field unavailable for editing in asp.net (C #)

I create one ASP web application, in this application one form should update the date value in the text field field. I put a calendar button next to this text box. it can update the date in this text box field, but it can be changed. I want the update date value to be used only with the calendar button, I used the read-only property, but returned an empty value, therefore it does not work.

+6
source share
6 answers

Try the html attribute readonlyon the client side instead of the ASP.NET server side readonly.

myTextBox.Attributes.Add("readonly", "readonly");

From MSDN,

TextBox ReadOnly, true, , , . , . Text postbacks, .

readonly .

+10

TextBox1.Enabled = false;

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

, enabled= false, textbox. textbox, textbox.

+3

:

yourTextBoxName.Attributes.Add("readonly","readonly");

,

Enabled="false"

aspx, .

+1

, :

TextBox1.Enabled = false;
0

textBox asp.net

0

, java-

onkeydown="javascript:return false"

, ,

0

All Articles