Markus Jansson
Top achievements
Rank 1
Markus Jansson
asked on 26 Nov 2009, 10:22 AM
Hi!
Just a simple question. How do I get the text value of a RadTimePicker control in the code behind? I have searched for it but can't seem to find it. There is a DateInput.Text property but that doesn't show the text written. I must be able to distinguish between an empty control and an invalid one. So, if someone for example writes "xyz" into the control, where do I find this value?
Thanks!
Just a simple question. How do I get the text value of a RadTimePicker control in the code behind? I have searched for it but can't seem to find it. There is a DateInput.Text property but that doesn't show the text written. I must be able to distinguish between an empty control and an invalid one. So, if someone for example writes "xyz" into the control, where do I find this value?
Thanks!
5 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 26 Nov 2009, 11:34 AM
Hi Markus Janson,
I tried following code in order to get the text typed by user evenif its is invalid and found it is working fine for me.
string str1 = RadTimePicker1.DateInput.Text.ToString();
Another option is getting the typed value (which is invalid) from client side and saving in a HiddenField control, so that you can check from the code behind.
aspx:
javascript:
cs:
-Shinu.
I tried following code in order to get the text typed by user evenif its is invalid and found it is working fine for me.
string str1 = RadTimePicker1.DateInput.Text.ToString();
Another option is getting the typed value (which is invalid) from client side and saving in a HiddenField control, so that you can check from the code behind.
aspx:
<telerik:RadTimePicker ID="RadTimePicker1" runat="server"> |
<DateInput> |
<ClientEvents OnError="OnError" /> |
</DateInput> |
</telerik:RadTimePicker> |
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Get the Text" /> |
<asp:HiddenField ID="HiddenField1" runat="server" /> |
javascript:
<script type="text/javascript"> |
function OnError(sender, args) { |
alert("Invalid Date :" + args.get_inputText()); |
document.getElementById("HiddenField1").value = args.get_inputText(); |
} |
</script> |
cs:
string temp = HiddenField1.Value; |
-Shinu.
0
Hi Markus,
You can obtain the invalid content of the DateInput textbox server-side like this:
RadTimePicker1.DateInput.ValidationDate
Kind regards,
Dimo
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
You can obtain the invalid content of the DateInput textbox server-side like this:
RadTimePicker1.DateInput.ValidationDate
Kind regards,
Dimo
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Markus Jansson
Top achievements
Rank 1
answered on 26 Nov 2009, 12:17 PM
Hi both Shinu and Dimo and thanks for quick responses!
However I'm afraid none of the code behind properties (haven't tried the one including client side yet) seem to work, at least not for me. If I make a simple page with this aspx:
and this VB:
and then run the page, enter an invalid time, like "xyz", and click the button, the textboxes remain empty.
Do you get a different result with the same code and, if so, why?
Regards,
Markus
However I'm afraid none of the code behind properties (haven't tried the one including client side yet) seem to work, at least not for me. If I make a simple page with this aspx:
<body> |
<form id="form1" runat="server"> |
<div> |
<telerik:RadScriptManager ID="RadScriptManager1" Runat="server"> |
</telerik:RadScriptManager> |
<br /> |
<telerik:RadTimePicker ID="RadTimePicker1" Runat="server"> |
</telerik:RadTimePicker> |
<br /> |
<asp:Button ID="Button1" runat="server" Text="Button" /> |
<br /><br /> |
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> |
<br /> |
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> |
</div> |
</form> |
</body> |
and this VB:
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click |
TextBox1.Text = RadTimePicker1.DateInput.Text.ToString |
TextBox2.Text = RadTimePicker1.DateInput.ValidationDate |
End Sub |
and then run the page, enter an invalid time, like "xyz", and click the button, the textboxes remain empty.
Do you get a different result with the same code and, if so, why?
Regards,
Markus
0
Accepted
Hello Markus,
The method I suggested will work with RadControls Q3 2009 (2009.3.1103) and later versions. For earlier versions the only way to find out what the user has entered inside the textbox is to examine the array of posted values and look for the following key:
Request.Params("RadTimePicker1_dateInput_text")
Regards,
Dimo
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
The method I suggested will work with RadControls Q3 2009 (2009.3.1103) and later versions. For earlier versions the only way to find out what the user has entered inside the textbox is to examine the array of posted values and look for the following key:
Request.Params("RadTimePicker1_dateInput_text")
Regards,
Dimo
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Markus Jansson
Top achievements
Rank 1
answered on 27 Nov 2009, 02:15 PM
Hi Dimo,
I tried upgrading to Q3 but ran into some problems in other areas so I went back to Q2.
Anyway the other solution you suggested (Request.Params) worked like a charm so I'm happy now.
Many thanks!
Regards,
Markus
I tried upgrading to Q3 but ran into some problems in other areas so I went back to Q2.
Anyway the other solution you suggested (Request.Params) worked like a charm so I'm happy now.
Many thanks!
Regards,
Markus