TextBox Readonly Property
-
When i am setting the Readonly property of a textbox to true and then, changing the textbox's value, The changed value doesn't get populated to the server on postback. Is there any alternative for this. I achieved this by setting the txtName.Attributes.Add("readonly", "readonly"); Need your comment if there is any better method.
Anurag Gandhi.
http://www.gandhisoft.com
Life is a computer program and every one is the programmer of his own life. -
When i am setting the Readonly property of a textbox to true and then, changing the textbox's value, The changed value doesn't get populated to the server on postback. Is there any alternative for this. I achieved this by setting the txtName.Attributes.Add("readonly", "readonly"); Need your comment if there is any better method.
Anurag Gandhi.
http://www.gandhisoft.com
Life is a computer program and every one is the programmer of his own life.I'm not sure what you're trying to achieve here? Scenario 1: You want to be able to alter the text so that it gets posted back to the server but in which case...why are you trying to make it read only? Read only means just that, you're not meant to change it. Scenario 2: You want the text to be unchangeable. Use the .enabled flag to false on the control.
-
When i am setting the Readonly property of a textbox to true and then, changing the textbox's value, The changed value doesn't get populated to the server on postback. Is there any alternative for this. I achieved this by setting the txtName.Attributes.Add("readonly", "readonly"); Need your comment if there is any better method.
Anurag Gandhi.
http://www.gandhisoft.com
Life is a computer program and every one is the programmer of his own life.It is not allowed to change the value of the textbox which is readonly. When it is readonly then why are you changing it. What is your requirement?
Cheers!! Brij Check my latest Article :A walkthrough to Application State
-
It is not allowed to change the value of the textbox which is readonly. When it is readonly then why are you changing it. What is your requirement?
Cheers!! Brij Check my latest Article :A walkthrough to Application State
The textbox is readonly for the user. But i want to change it through javascript based on some criteria and get the changed value to the server.
Anurag Gandhi.
http://www.gandhisoft.com
Life is a computer program and every one is the programmer of his own life. -
When i am setting the Readonly property of a textbox to true and then, changing the textbox's value, The changed value doesn't get populated to the server on postback. Is there any alternative for this. I achieved this by setting the txtName.Attributes.Add("readonly", "readonly"); Need your comment if there is any better method.
Anurag Gandhi.
http://www.gandhisoft.com
Life is a computer program and every one is the programmer of his own life.Anurag Gandhi wrote:
the Readonly property of a textbox to true and then, changing the textbox's value,
How are you able to change a value of textbox when it's readonly? Readonly means you cannot change. & If you want to change why readonly?
-
Anurag Gandhi wrote:
the Readonly property of a textbox to true and then, changing the textbox's value,
How are you able to change a value of textbox when it's readonly? Readonly means you cannot change. & If you want to change why readonly?
Sorry for my initial post. I am changing the textbox value in the the client side using Javascript.
Anurag Gandhi.
http://www.gandhisoft.com
Life is a computer program and every one is the programmer of his own life. -
Sorry for my initial post. I am changing the textbox value in the the client side using Javascript.
Anurag Gandhi.
http://www.gandhisoft.com
Life is a computer program and every one is the programmer of his own life.You have marked the field as readonly. You wont be able to change it and thus you don't find the change on server side. If you want to use a changed value of the shown readonly field, use hidden field for it. Set the new value in hidden field and access it in code-behind.
-
The textbox is readonly for the user. But i want to change it through javascript based on some criteria and get the changed value to the server.
Anurag Gandhi.
http://www.gandhisoft.com
Life is a computer program and every one is the programmer of his own life.One more way, you can do this use a property
ContentEditable
make it false, then you'll be able to update it from client side.But you'll get some warning for this property.Otherwise better way do as Sandeep suggested.Cheers!! Brij Check my latest Article :A walkthrough to Application State
-
You have marked the field as readonly. You wont be able to change it and thus you don't find the change on server side. If you want to use a changed value of the shown readonly field, use hidden field for it. Set the new value in hidden field and access it in code-behind.
Can you not just disable the textbox and then change the text property? Then it will appear as if readonly but you should still be able to change the value.
-
Can you not just disable the textbox and then change the text property? Then it will appear as if readonly but you should still be able to change the value.
Yes we can, it's just that disabled text would be light grayed... and evident that its disabled. If it's not a concerning issue then surely we can go for it. It's just that, one prefers readonly because of the text visibility in general.
-
When i am setting the Readonly property of a textbox to true and then, changing the textbox's value, The changed value doesn't get populated to the server on postback. Is there any alternative for this. I achieved this by setting the txtName.Attributes.Add("readonly", "readonly"); Need your comment if there is any better method.
Anurag Gandhi.
http://www.gandhisoft.com
Life is a computer program and every one is the programmer of his own life. -
One more way, you can do this use a property
ContentEditable
make it false, then you'll be able to update it from client side.But you'll get some warning for this property.Otherwise better way do as Sandeep suggested.Cheers!! Brij Check my latest Article :A walkthrough to Application State
Brij wrote:
you can do this use a property ContentEditable
Do we have such Property for TextBox in Asp.Net 4.0??
Anurag Gandhi.
http://www.gandhisoft.com
Life is a computer program and every one is the programmer of his own life.