Click here to Skip to main content
15,878,809 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
**Hello Guys,**

I have a normal asp.net Text Box with `Enabled = false;` Property.

when i try to set its value using java Script it works fine actually

But if the page posted back it looses its value.

how can i make it keeps its value?

Any Ideas?
Posted

Here is an article[^] that has a good idea.
 
Share this answer
 
Comments
Manas Bhardwaj 15-Apr-14 16:17pm    
The link has good discussion about the post back topic. But I am not in favor of abusing the disabled textbox value via JS. Please see my answer.
Richard C Bishop 15-Apr-14 16:29pm    
Indeed, good alternative.
_ProgProg_ 15-Apr-14 16:23pm    
actually this link is not what i want but thanks for your effort
Richard C Bishop 15-Apr-14 16:29pm    
No problem, good luck.
I don't think you want to use Enabled as false. The purpose of enabled property is to have it available or not.

And if you have enabled as false, why do you want to abuse the property just because you can do it with some sort of client side script.

I would suggest to used ReadOnly property if you want to block the access of textbox by user.

Or you can also take help of Css to make it look like disabled/readonly.
 
Share this answer
 
Comments
_ProgProg_ 15-Apr-14 16:19pm    
you are right in your thinking, But i am setting its value on another check box checked changed
so when it is checked, this text box value should be 1 else it should be false
_ProgProg_ 15-Apr-14 16:35pm    
I 've tried the readonly property and the same problem exist
Bh@gyesh 16-Apr-14 1:42am    
Hi,
You can use jquery insted. First of all in docun=ment.ready method, make textbox enable false so when page is postback it will remain enable false.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900