i have a problem regarding textbox.problem is when is set readonly "TRUE" of a textbox and need to save the value of the textbox then the value of the textbox is null or Zero.
so, what to do here in a readonly "True" textbox value?
It seems the problem is not with the readonly property. Please check ur code whether u r assigning a null or zero value for the text box anywhere else.
i have a problem regarding textbox.problem is when is set readonly "TRUE" of a textbox and need to save the value of the textbox then the value of the textbox is null or Zero.
so, what to do here in a readonly "True" textbox value?
That's obvious,readonly is set to controls that meant to be viewed only,not to read from it later on.
To fix the issue:
1)set the readonly to false.
2)when you want to set a textbox to readonly,use this line:
TextBox1.Attributes.Add("readonly",readonly");
unless you want to set it to readonly by default (from html),do it like this:
<asp:TextBox ...... readonly="readonly"...
Best Regards,
Ala'a Alnajjar
----------------------------------------------------
My Webblog
When you set the read only property of a textbox to true, the system assumes that read only or disabled controls won't be changed clientside so it doesn't post the changed value back to the server. You need to set the client side readonly property rather
than the serverside version.
Subhakanta
Member
256 Points
796 Posts
textbox problem
Oct 05, 2009 09:44 AM|LINK
hi,
i have a problem regarding textbox.problem is when is set readonly "TRUE" of a textbox and need to save the value of the textbox then the value of the textbox is null or Zero.
so, what to do here in a readonly "True" textbox value?
please solved it.
Thanking you.
karthicks
All-Star
31376 Points
5421 Posts
Re: textbox problem
Oct 05, 2009 11:32 AM|LINK
dont set Readonly in .aspx page, instead of do it page_load using below code
text.Attributes.Add("readonly", "true");
Karthick S
MetalAsp.Net
All-Star
112085 Points
18242 Posts
Moderator
Re: textbox problem
Oct 05, 2009 11:35 AM|LINK
Try reading the value the old fashion way via the Request["YourTbId"].
suthish nair
All-Star
15176 Points
3304 Posts
Re: textbox problem
Oct 05, 2009 11:53 AM|LINK
can you post your mark up code.. check whether you again resetting the value of textbox
My Blog
DotnetDevelo...
Member
40 Points
13 Posts
Re: textbox problem
Oct 05, 2009 11:59 AM|LINK
u can do it by javascript
for ex:-
function SetOtherField(field1,field2) //field1 is dropdown having 'Other' option ,field2 is Textbox
{
if(field1.value=="Other")
{
field2.readOnly=false;
}
else
{
field2.readOnly=true;
field2.value="";
}
}
tecktree
Member
720 Points
166 Posts
Re: textbox problem
Oct 05, 2009 12:04 PM|LINK
Hi,
It seems the problem is not with the readonly property. Please check ur code whether u r assigning a null or zero value for the text box anywhere else.
alaa9jo
Star
11375 Points
2036 Posts
Re: textbox problem
Oct 05, 2009 12:24 PM|LINK
That's obvious,readonly is set to controls that meant to be viewed only,not to read from it later on.
To fix the issue:
1)set the readonly to false.
2)when you want to set a textbox to readonly,use this line:
TextBox1.Attributes.Add("readonly",readonly");
unless you want to set it to readonly by default (from html),do it like this:
<asp:TextBox ...... readonly="readonly"...
Ala'a Alnajjar
----------------------------------------------------
My Webblog
sunny74
Participant
1494 Points
782 Posts
Re: textbox problem
Oct 05, 2009 12:30 PM|LINK
Hi
When you set the read only property of a textbox to true, the system assumes that read only or disabled controls won't be changed clientside so it doesn't post the changed value back to the server. You need to set the client side readonly property rather than the serverside version.
So follow this link for a solution,
http://stackoverflow.com/questions/833884/why-does-a-read-only-textbox-does-not-return-any-data-in-asp-net
PLS MARK MY REPLY "AS ANSWER" IF IT HELPED YOU.