RadTextBox and Javascript

2 posts, 1 answers
  1. DK
    DK avatar
    72 posts
    Member since:
    Jun 2009

    Posted 21 Jul 2009 Link to this post

    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
  2. Answer
    Dimo
    Admin
    Dimo avatar
    8450 posts

    Posted 21 Jul 2009 Link to this post

    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.
Back to Top