I have a date input where a user can choose to enter a date and time, or they can click on a button to load the current date and time. I would prefer to set the value with client-side code if they click the button, but I cannot get it to work. It will enter the current date, but not the time. My control looks like:
If I click on the button, the results will have the right date but not the time. For example, if I run it right now I get "02/11/2011 00:00" inserted in the raddateinput field, while the alert shows "toDay = Fri Feb 11 15:56:36 CST 2011".
If I remove the OnClientClick parameter from the button, it will execute the server-side code that I have coded for the button. It looks like:
The results are now '02/11/2011 15:57".
How do I need to code the client-side code so that it properly loads both the date and the time in the control?
Thank you!
<
telerik:RadCodeBlock
ID
=
"RadCodeBlock1"
runat
=
"server"
>
<
script
language
=
"javascript"
type
=
"text/javascript"
>
function setDateTimeAcknowledged() {
var toDay = new Date();
alert("toDay = " + toDay);
var dateInput = $find("<%= dateAcknowledged.ClientID %>");
dateInput.set_selectedDate(toDay);
}
function setEstReturnDate() {
var toDay = new Date();
var dateInput = $find("<%= dateEstimatedReturn.ClientID %>");
dateInput.set_selectedDate(toDay);
}
</
script
>
</
telerik:RadCodeBlock
>
...
<
telerik:RadDateInput
ID
=
"dateAcknowledged"
runat
=
"server"
DisplayDateFormat
=
"MM/dd/yyyy HH:mm"
Width
=
"125"
CssClass
=
"NotRequired"
/>
<
telerik:RadToolTip
ID
=
"tipDateAcknowledge"
runat
=
"server"
HideEvent
=
"LeaveTargetAndToolTip"
TargetControlID
=
"dateAcknowledged"
Position
=
"BottomRight"
RelativeTo
=
"Element"
ShowEvent
=
"OnMouseOver"
Text
=
"mm/dd/yyyy HH:mm (24HR) format less than or equal to today's date"
/>
<
asp:Button
ID
=
"btnAckNow"
runat
=
"server"
Text
=
"Now"
CausesValidation
=
"false"
OnClientClick
=
"setDateTimeAcknowledged(); return false;"
/>
If I click on the button, the results will have the right date but not the time. For example, if I run it right now I get "02/11/2011 00:00" inserted in the raddateinput field, while the alert shows "toDay = Fri Feb 11 15:56:36 CST 2011".
If I remove the OnClientClick parameter from the button, it will execute the server-side code that I have coded for the button. It looks like:
Protected
Sub
btnAckNow_Click(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
btnAckNow.Click
dateAcknowledged.SelectedDate =
Date
.Now
End
Sub
The results are now '02/11/2011 15:57".
How do I need to code the client-side code so that it properly loads both the date and the time in the control?
Thank you!