This is a migrated thread and some comments may be shown as answers.

How to access the input box in RAD Date picker control

6 Answers 425 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Viswanathan
Top achievements
Rank 1
Viswanathan asked on 27 Jul 2009, 12:44 PM
Hi,

Can anyone tell me that how can we access the input box in RAD Date picker control?

I explored some url and found that get_textBox() method will get us the text box, but it doesn't worked for me! Could any one have working solution for this?

Thanks in advance
Viswa

6 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 27 Jul 2009, 01:16 PM
Hi Viswanathan,

I tried the following code and it worked fine as expected. Have a look at the following code.

ASPX:
 
<telerik:RadDatePicker ID="RadDatePicker1" runat="server"
</telerik:RadDatePicker> 

JavaScript:
 
<script type="text/javascript"
function getTextBox() 
    var datepicker = $find("<%= RadDatePicker1.ClientID %>"); 
    var textbox = datepicker.get_textBox()
    alert(textbox.value); 
</script> 
Could you paste the code that you tried if that is different from my code?

-Shinu
0
Viswanathan
Top achievements
Rank 1
answered on 27 Jul 2009, 03:40 PM
Hi Shinu,

Here is my code:

aspx declaration: (i've placed the rad date picker inside EditItemTemplate of RAD Grid. What i'm trying to do is on clicking on the image 'imgLastEventDate', i need to update the date value)

<rad:RadDatePicker ID="dtpLastEventDate" runat="server" Width="75px" >
   <DateInput Skin="Office2007" runat="server" MaxLength="10">
<ClientEvents OnError="DateFieldError" />
   </DateInput>
   <Calendar Skin="Office2007" runat="server" ShowRowHeaders="false" BorderWidth="1px"
BorderColor="ActiveBorder">
   </Calendar>
</rad:RadDatePicker>
<asp:Image ID="imgLastEventDate" runat="server" ToolTip="Today's Date" />


c#

        protected void grdViewRegistries_ItemDataBound(object sender, Telerik.WebControls.GridItemEventArgs e)
        {
if (e.Item is GridEditableItem)
{
   if (e.Item.IsInEditMode)
   {
imgLastEventDateTodaysDate.Attributes.Add("onclick", "GetTodaysDate('" + dtpLastEventDate.ClientID + "'); return false;");
   }
}
}

javascript:

function GetTodaysDate(datePickerId)
{
var datepicker = $find(datePickerId); 
var textbox = datepicker.get_textBox(); 
alert(textbox.value);
}

I'm getting the following error:

Microsoft JScript runtime error: 'null' is null or not an object

'datepicker' itself is getting 'null' for me!

Let me know whether i've missed anything.

Thanks
Viswa
0
Accepted
Princy
Top achievements
Rank 2
answered on 28 Jul 2009, 07:02 AM
Hello Viswa,

I hope you are using RadDatePicker for Asp.Net version. If thats the case then you would have to modify your javascript as shown below:
js:
function GetTodaysDate(datePickerId) 
        {         
        var datepicker = window[datePickerId];  
        var textbox = datepicker.GetTextBox();  
        alert(textbox.value); 
        } 

This should probably help you resolve your error:
-Princy :)
0
Viswanathan
Top achievements
Rank 1
answered on 28 Jul 2009, 07:12 AM
Hi Princy,

Thanks for your reply. But i already found the solution the same way you did. :-)

Just out of curiosity, i wanna know 
whats the difference b/w the RAD Date picker control for asp.net version and the one specified by Shinu.
Please explain me.

Thanks
Viswa
0
Princy
Top achievements
Rank 2
answered on 28 Jul 2009, 07:32 AM
Hi Viswa,

The code which Shinu gave was for RadDatePicker for ASP.NET AJAX and the code which I have given above is for RadDatePicker ASP.NET. You may Go through the following help articles to get more details about both.

RadCalendar for ASP.NET
RadCalendar for ASP.NET AJAX

Regards
Princy
0
Viswanathan
Top achievements
Rank 1
answered on 28 Jul 2009, 12:56 PM
Hi Princy,

Thanks for the reference articles. I'm clear now. :-)

Thanks
Viswa
Tags
Calendar
Asked by
Viswanathan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Viswanathan
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or