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
</
}
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~
Hello Ho, thanks for you help so far. The script looks good only I receive an error:
'Can't Eval fDateClicked(oControl, ig_fireEvent.arguments[2], ig_fireEvent.arguments[3]);'
This I have in my .aspx page:
<script type="text/javascript" id="Infragistics"> function fDateClicked(oCalendar, oDate, oEvent) { //Add code to handle your event here. 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("txtDate"); textbox.value = text; }
</script>
Thanks in advance.