Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
385
Display Selected Date from Webcalendar in ASP.NET textbox
posted

Hello, in the client side javascript I would like to display the selected date in a textbox. When I read the oDatevalue and show it via the Alert function, I see the full date and time. How I can put this date (only) in the ASP.NET textbox named txtDate. The problem is that javscript doesn't know the field txtDate in the rendered page I think and I don't know to put it in the textbox. How to achieve this? Thanks in advance.
Ps. the webcalendar is placed on a template field column from a standard ASP.NET webgrid. (Insert Item template)

 <script type="text/javascript" id ="Infragistics">  

function  fDateClicked(oCalendar, oDate, oEvent) { 

 

 

txtdate.text=oDate

</

 

 

script>

}

//Add code to handle your event here.

Parents
No Data
Reply
  • 5389
    Suggested Answer
    posted

    arjanxp,

    You will have to use javascript to break up the oDate variable into pieces (month, date, year), and then put the pieces together.  For example:

     var month = oDate.getMonth() + 1;   //month is zero-based, so add 1
     var day = oDate.getDate();
     var year = oDate.getYear();
     var text = month +"/" + day + "/" + year;
     var textbox = document.getElementById("TextBox1");
     textbox.value = text;

    So if you selected today's date, March 24, 2009 in the WebCalendar, the text in the TextBox will read "3/24/2009".

     

    Hope this helps,

    ~Kim~

Children