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

RadTextBox and Javascript

1 Answer 440 Views
Input
This is a migrated thread and some comments may be shown as answers.
DK
Top achievements
Rank 2
DK asked on 21 Jul 2009, 12:06 PM
Hi
 I have a  RadTextbox on the page.
now on page load i want to set the value of the radtextbox to the Client dateteim.
i have used the following code


window.onload = function fillText()
{
var txtDate=document.getelementbyid("txtDate");
txtDate.Value="Date from javascript";
}


but this code is not working please help me

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimo
Telerik team
answered on 21 Jul 2009, 12:26 PM
Hi DK,

I strongly recommend getting familiar with the RadTextBox client side API first:

http://www.telerik.com/help/aspnet-ajax/input_clientsidebasics.html

http://www.telerik.com/help/aspnet-ajax/input_clientsideradtextbox.html


Please use the following Javascript code:

Sys.Application.add_load(myfunction); 
 
function myfunction() 
       var txtDate = $find("txtDate"); 
       txtDate.set_value("Date from javascript"); 


On a side note, for dates we recommend using RadDateInput instead of RadTextBox.

http://www.telerik.com/help/aspnet-ajax/input_clientsideraddateinput.html

In this case you can use the set_selectedDate() method, which accepts a Javascript Date object as a parameter.


Regards,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Input
Asked by
DK
Top achievements
Rank 2
Answers by
Dimo
Telerik team
Share this question
or