469,964 Members | 1,546 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,964 developers. It's quick & easy.

Why Readonly Text box values are empty in code behind ?

Hi all,
In my web page, why the read only text box's value becomes empty in the code behind file. I use ASP.net .I calculate the difference of two dates in js and display it in a readonly text box. But this value is empty in code behind and I couldn't save it database. How to resolve this? can any one help? Previously i used hidden fields to get these values. Is this efficient way? Plz tell me...
Dec 27 '07 #1
3 8609
nateraaaa
663 Expert 512MB
Hi all,
In my web page, why the read only text box's value becomes empty in the code behind file. I use ASP.net .I calculate the difference of two dates in js and display it in a readonly text box. But this value is empty in code behind and I couldn't save it database. How to resolve this? can any one help? Previously i used hidden fields to get these values. Is this efficient way? Plz tell me...
Do you have a runat = server tag in the html portion of your aspx page?

[HTML]<asp:TextBox id="TextBox1" runat="server" ReadOnly="true"/>[/HTML]

Nathan
Dec 27 '07 #2
Do you have a runat = server tag in the html portion of your aspx page?

[HTML]<asp:TextBox id="TextBox1" runat="server" ReadOnly="true"/>[/HTML]

Nathan
yes, I have runat="server" tag.Only the text becomes empty.(TextBox1.Text=""). But there is value displayed in the UI.
Dec 28 '07 #3
Hi,

I was working with the same senario. Here is the solution i used for that. Hope it helps you.

<asp:TextBox ID="txtStartDate" runat="server" Width="70px" CssClass="txtFormat" onfocus="this.blur();"></asp:TextBox>

add onfocus="this.blur()"; to the text box attributes.

this will set the focus back to the form whenever user tries to set focus on text box. You can use the values in textbox in code behind too :-)
Apr 9 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by Tony Cooke | last post: by
3 posts views Thread by Gary Homewood | last post: by
3 posts views Thread by Lyners | last post: by
16 posts views Thread by mj.redfox.mj | last post: by
1 post views Thread by rainxy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.