I'm trying to set the value of a WebDateChooser using javascript. However, the value never gets set, it just defaults to null. Is it possible to set a WevDateChooser value using javascript? if yes, how do i do this?
HI
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<%@ Register Assembly="Infragistics2.WebUI.WebDateChooser.v7.3, Version=7.3.20073.38, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" Namespace="Infragistics.WebUI.WebSchedule" TagPrefix="igsch" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title><script language="javascript" type="text/javascript">// <!CDATA[var dchooser = null;function Button1_onclick() {//debugger;var dt = new Date(); dchooser.setValue(dt);}
// ]]>
function WebDateChooser1_InitializeDateChooser(oDateChooser){ //Add code to handle your event here. dchooser = oDateChooser;}// --></script></head><body> <form id="form1" runat="server"> <div> <igsch:WebDateChooser ID="WebDateChooser1" runat="server" OnInit="WebDateChooser1_Init"> <ClientSideEvents InitializeDateChooser="WebDateChooser1_InitializeDateChooser" /> </igsch:WebDateChooser> </div> <input id="Button1" type="button" value="button" onclick="return Button1_onclick()" /> </form></body></html>
Though your resolution appears to be correct I cannot get setValue to work at all. I always get an 'undefined' value when checking the value after having tried to change it:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="wade_test.aspx.vb" Inherits="Forms_wade_test" %><%@ Register TagPrefix="igsch" Namespace="Infragistics.WebUI.WebSchedule" Assembly="Infragistics2.WebUI.WebDateChooser.v7.3, Version=7.3.20073.38, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title> <script type="text/javascript" language="javascript"> var oStartTimeGenDateCtl = null; var oEndTimeGenDateCtl = null; var oStartTimeWritDateCtl = null; var oEndTimeWritDateCtl = null; function InitDateChooser(oDateChooser) { oStartTimeGenDateCtl = oDateChooser; } function DateChooserValueChanged(oDateChooser, oValue) { alert(oValue); } function SetDate() { var oDate = new Date(); oStartTimeGenDateCtl.setValue = oDate.getDate(); alert(oStartTimeGenDateCtl.Id); alert(oStartTimeGenDateCtl.getValue()); return false; } </script></head><body> <form id="form1" runat="server"> <div> <igsch:webdatechooser ID="txtStartTimeGenerated" Runat="server" BorderWidth="1px" TabIndex="3" BorderStyle="Solid" Visible="true" NullDateLabel="" Editable="true"> <CalendarLayout FooterFormat="Today: {0:d}"></CalendarLayout> <ExpandEffects ShadowColor="LightGray"></ExpandEffects> <ClientSideEvents InitializeDateChooser="InitDateChooser" ValueChanged="DateChooserValueChanged"/> </igsch:webdatechooser>
<asp:Button ID="cmdSetDate" runat="server" Text="Set Dates" OnClientClick="return SetDate();" /> </div> </form></body></html>
Nevermind. I figured it out. Been staring at code too long this week.
Hi wrenn,
you are not using the setValue method correctly.
oStartTimeGenDateCtl.setValue = oDate.getDate(); - this is not corect.
try this structure - remember setValue is a method
oStartTimeGetDateCtl.setValue(oDate.getDate()) - this is the proper structure