Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 23, 2012 08:47 AM by stylish16
Member
13 Points
68 Posts
May 23, 2012 05:12 AM|LINK
Dear Members,
I have calculate date from javascript and displaying it in asp:textbox. It is displayed correctly in it.
But, problem I am facing is that, if i tried to get date from textbox, it is returning "".
Please Help me in this issue.
Participant
1596 Points
378 Posts
May 23, 2012 05:17 AM|LINK
What mechanism you used to display and assign value in textbox?
To display use:
document.getElementByID("TextboxID").innerHTML=Date;
TO assign value to the textbox:
document.getElementByID("TextboxID").value=Date;
To perform both,you have to use both the line:
52 Points
18 Posts
May 23, 2012 06:03 AM|LINK
Hai,
From where you try to facthing, whether it is from javascript or code behind?
Can you please provide the source code for this.?
May 23, 2012 06:37 AM|LINK
Hi,
I have set date in asp:textbox through javascript.
It is showing on form correctly after executing.
But, if i use txtbx.Text in code behind, then it gives value as ""
May 23, 2012 06:52 AM|LINK
Have you assigned values in javascript as(please note the ID of textbox) follow ?
document.getElementById('<%=txtbx.ClientID%>').value="Date";
If yes, and still not working please show your code (js and code behind).
727 Points
155 Posts
May 23, 2012 07:00 AM|LINK
Is the textbox readonly property set to true in aspx.
If yes, then remove the readonly property in the aspx and set it in the pageload like
txtbx.Attributes.Add("readonly", "true");
May 23, 2012 07:10 AM|LINK
Readonly property not set to true.
I have set only enabled property to false.
Contributor
2222 Points
436 Posts
May 23, 2012 08:06 AM|LINK
stylish16 I have set only enabled property to false.
Disabled controls do not get submitted with the form. The value that you set thru Javascript won't reach the server.
May 23, 2012 08:15 AM|LINK
Hi Abhishek,
You solved my problem.
I have set Enable property to true again.
But, New Issue arise.
User can directly change date from his side.
Please suggest some way to tackle this.
Thanks for the help.
May 23, 2012 08:22 AM|LINK
Do One thing, set enabled to true in the aspx.
Set readonly to true in the codebehind as I suggested.
That way, the user wont be able to change the value , and the value assigned to the textbox can be read by using txtbx.Text
stylish16
Member
13 Points
68 Posts
Not getting date from asp:textbox
May 23, 2012 05:12 AM|LINK
Dear Members,
I have calculate date from javascript and displaying it in asp:textbox. It is displayed correctly in it.
But, problem I am facing is that, if i tried to get date from textbox, it is returning "".
Please Help me in this issue.
mishra.bhupe...
Participant
1596 Points
378 Posts
Re: Not getting date from asp:textbox
May 23, 2012 05:17 AM|LINK
What mechanism you used to display and assign value in textbox?
To display use:
document.getElementByID("TextboxID").innerHTML=Date;
TO assign value to the textbox:
document.getElementByID("TextboxID").value=Date;
To perform both,you have to use both the line:
document.getElementByID("TextboxID").innerHTML=Date;
document.getElementByID("TextboxID").value=Date;
Pince
Member
52 Points
18 Posts
Re: Not getting date from asp:textbox
May 23, 2012 06:03 AM|LINK
Hai,
From where you try to facthing, whether it is from javascript or code behind?
Can you please provide the source code for this.?
stylish16
Member
13 Points
68 Posts
Re: Not getting date from asp:textbox
May 23, 2012 06:37 AM|LINK
Hi,
I have set date in asp:textbox through javascript.
It is showing on form correctly after executing.
But, if i use txtbx.Text in code behind, then it gives value as ""
mishra.bhupe...
Participant
1596 Points
378 Posts
Re: Not getting date from asp:textbox
May 23, 2012 06:52 AM|LINK
Have you assigned values in javascript as(please note the ID of textbox) follow ?
document.getElementById('<%=txtbx.ClientID%>').value="Date";
If yes, and still not working please show your code (js and code behind).
Ravi Kumar K...
Member
727 Points
155 Posts
Re: Not getting date from asp:textbox
May 23, 2012 07:00 AM|LINK
Is the textbox readonly property set to true in aspx.
If yes, then remove the readonly property in the aspx and set it in the pageload like
txtbx.Attributes.Add("readonly", "true");
stylish16
Member
13 Points
68 Posts
Re: Not getting date from asp:textbox
May 23, 2012 07:10 AM|LINK
Hi,
Readonly property not set to true.
I have set only enabled property to false.
Abhishek Bha...
Contributor
2222 Points
436 Posts
Re: Not getting date from asp:textbox
May 23, 2012 08:06 AM|LINK
Disabled controls do not get submitted with the form. The value that you set thru Javascript won't reach the server.
stylish16
Member
13 Points
68 Posts
Re: Not getting date from asp:textbox
May 23, 2012 08:15 AM|LINK
Hi Abhishek,
You solved my problem.
I have set Enable property to true again.
But, New Issue arise.
User can directly change date from his side.
Please suggest some way to tackle this.
Thanks for the help.
Ravi Kumar K...
Member
727 Points
155 Posts
Re: Not getting date from asp:textbox
May 23, 2012 08:22 AM|LINK
Do One thing, set enabled to true in the aspx.
Set readonly to true in the codebehind as I suggested.
That way, the user wont be able to change the value , and the value assigned to the textbox can be read by using txtbx.Text