Welcome Guest Search | Active Topics | Sign In | Register

Using setSelectedDate(null) Resets Date on Second Control Options
crmdude
Posted: Thursday, November 13, 2008 12:23:40 PM
Rank: Newbie
Groups: Member

Joined: 11/13/2008
Posts: 2
I am evaluating Calendar objects as a Date and Time Picker using the DEMO sample provided in the evaluation download.

I modified Date and Time Picker demo code as follows. Now when I click cmdSetToNow the date gets populated correclty in the correct control. However, if I click cmdReset, BOTH controls are cleared. Is there something I am doing wrong?

I will appreciate a quick response.

Thanks in advance





Markup

<%@ Control language="VB" AutoEventWireup="false" CodeFile="Demo.ascx.vb" Inherits="EO.Web.Demo.Demos.Calendar.Features.Date_and_Time_Picker.Demo" %>
<%@ Register TagPrefix="eo" NameSpace="EO.Web" Assembly="EO.Web" %>
<p>
EO.Web DatePicker can also be used to enter both date and time. To enable this
feature, simply uses one or more supported time related specifiers in <strong>PickerFormat</strong>.
The following DatePicker has its <strong>PickerFormat</strong> set to <span class="highlight">
MM/dd/yyyy hh:mm:ss tt</span>. Input must contains both date and time value
to be valid.
</p>
<eo:CallbackPanel runat="server" id="CallbackPanel1" Triggers="{ControlID:btnSubmit;Parameter:}">
<eo:DatePicker id="DatePicker1" runat="server" DayHeaderFormat="FirstLetter" TitleLeftArrowImageUrl="DefaultSubMenuIconRTL"
DayCellHeight="16" OtherMonthDayVisible="True" DayCellWidth="19" TitleRightArrowImageUrl="DefaultSubMenuIcon" ControlSkinID="None" PickerFormat="MM/dd/yyyy hh:mm:ss tt" DisabledDates="" SelectedDates="">
<TodayStyle CssText="border-right: #bb5503 1px solid; border-top: #bb5503 1px solid; border-left: #bb5503 1px solid; border-bottom: #bb5503 1px solid"/>
<SelectedDayStyle CssText="background-color: #fbe694; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid" />
<DisabledDayStyle CssText="color: gray; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid" />
<PickerStyle CssText="font-family:Arial; font-size:8pt; padding-left:5px; padding-right: 5px;" />
<CalendarStyle CssText="background-color: white; border-right: #7f9db9 1px solid; padding-right: 4px; border-top: #7f9db9 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; border-left: #7f9db9 1px solid; padding-top: 4px; border-bottom: #7f9db9 1px solid; font-family: tahoma" />
<TitleArrowStyle CssText="cursor:hand" />
<DayHoverStyle CssText="border-right: #fbe694 1px solid; border-top: #fbe694 1px solid; border-left: #fbe694 1px solid; border-bottom: #fbe694 1px solid" />
<MonthStyle CssText="font-size: 8pt; margin-left: 14px; cursor: hand; margin-right: 14px; font-family: tahoma" />
<TitleStyle CssText="background-color:#9ebef5;font-family:Tahoma;font-size:8pt;padding-bottom:2px;padding-left:6px;padding-right:6px;padding-top:2px;" />
<OtherMonthDayStyle CssText="color: gray; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid" />
<DayHeaderStyle CssText="border-bottom: #aca899 1px solid" />
<DayStyle CssText="BORDER-RIGHT: white 1px solid; BORDER-TOP: white 1px solid; FONT-SIZE: 8pt; BORDER-LEFT: white 1px solid; BORDER-BOTTOM: white 1px solid; FONT-FAMILY: Arial" />
</eo:DatePicker>
<asp:ImageButton ID="cmdSetToNow" runat="server" Height="15px" Width="15px" />
<asp:ImageButton ID="cmdReset" runat="server" Height="15px" Width="15px" />
<p>
<asp:Button id="btnSubmit" runat="server" Text="Submit"></asp:Button></p>
<p>
<asp:Label id="lblResult" Runat="server"></asp:Label>&nbsp;</p>
<p>
<eo:DatePicker id="DatePicker2" runat="server" DayHeaderFormat="FirstLetter"
TitleLeftArrowImageUrl="DefaultSubMenuIconRTL"
DayCellHeight="16" OtherMonthDayVisible="True" DayCellWidth="19" TitleRightArrowImageUrl="DefaultSubMenuIcon"
ControlSkinID="None" PickerFormat="MM/dd/yyyy hh:mm:ss tt" DisabledDates="" SelectedDates="">
<TodayStyle CssText="border-right: #bb5503 1px solid; border-top: #bb5503 1px solid; border-left: #bb5503 1px solid; border-bottom: #bb5503 1px solid"/>
<SelectedDayStyle CssText="background-color: #fbe694; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid" />
<DisabledDayStyle CssText="color: gray; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid" />
<PickerStyle CssText="font-family:Arial; font-size:8pt; padding-left:5px; padding-right: 5px;" />
<CalendarStyle CssText="background-color: white; border-right: #7f9db9 1px solid; padding-right: 4px; border-top: #7f9db9 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; border-left: #7f9db9 1px solid; padding-top: 4px; border-bottom: #7f9db9 1px solid; font-family: tahoma" />
<TitleArrowStyle CssText="cursor:hand" />
<DayHoverStyle CssText="border-right: #fbe694 1px solid; border-top: #fbe694 1px solid; border-left: #fbe694 1px solid; border-bottom: #fbe694 1px solid" />
<MonthStyle CssText="font-size: 8pt; margin-left: 14px; cursor: hand; margin-right: 14px; font-family: tahoma" />
<TitleStyle CssText="background-color:#9ebef5;font-family:Tahoma;font-size:8pt;padding-bottom:2px;padding-left:6px;padding-right:6px;padding-top:2px;" />
<OtherMonthDayStyle CssText="color: gray; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid" />
<DayHeaderStyle CssText="border-bottom: #aca899 1px solid" />
<DayStyle CssText="border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid" />
</eo:DatePicker>

</p>
<p>
<asp:Label id="Label1" Runat="server"></asp:Label>&nbsp;</p>

<p>
<asp:Button id="Button1" runat="server" Text="Submit"></asp:Button></p>


</eo:CallbackPanel>
<script language="javascript" type="text/javascript">

function setToNow(clientID)
{
eo_GetObject(clientID).setSelectedDate(new Date());

}

function reset(clientID)
{
eo_GetObject(clientID).setSelectedDate(null);
eo_HideAllPopups();

}
</script>




Code Behind


Imports System
Imports System.Data
Imports System.Drawing
Imports System.Web
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls

Namespace EO.Web.Demo.Demos.Calendar.Features.Date_and_Time_Picker

'/ <summary>
'/ Summary description for Demo.
'/ </summary>

Partial Class Demo
Inherits System.Web.UI.UserControl

Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load, Me.Load
DatePicker1.SelectedDate = DateTime.Now
cmdSetToNow.Attributes.Add("onClick", "javascript:setToNow('" & DatePicker2.ClientID & "'); return false;")
cmdReset.Attributes.Add("onClick", "javascript:reset('" & DatePicker2.ClientID & "'); return false;")

End Sub 'Page_Load

#Region "Web Form Designer generated code"

Protected Overrides Sub OnInit(e As EventArgs)
'
' CODEGEN: This call is required by the ASP.NET Web Form Designer.
'
InitializeComponent()
MyBase.OnInit(e)
End Sub 'OnInit


'/ <summary>
'/ Required method for Designer support - do not modify
'/ the contents of this method with the code editor.
'/ </summary>
Private Sub InitializeComponent()
End Sub 'InitializeComponent

#End Region


Private Sub btnSubmit_Click(sender As Object, e As System.EventArgs) Handles btnSubmit.Click
lblResult.Text = DatePicker1.SelectedDate.ToString("F")
Label1.Text = DatePicker2.SelectedDate.ToString("F")

End Sub 'btnSubmit_Click

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

DatePicker2.SelectedDateString = ""
End Sub

Protected Sub cmdSetToNow_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles cmdSetToNow.Click

End Sub
End Class 'Demo
End Namespace 'EO.Web.Demo.Demos.Calendar.Features.Date_and_Time_Picker
eo_support
Posted: Thursday, November 13, 2008 12:54:24 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,088
Hi,

The problem is the name of your function. You can not call it "reset". "reset" is a built-in function on the form object, and when it is called, it reset every input element in your form. So when you click the button, it's the form's reset method, not yours got called.

Try to change the function name to something else should resolve the issue.

Thanks!
crmdude
Posted: Thursday, November 13, 2008 2:52:23 PM
Rank: Newbie
Groups: Member

Joined: 11/13/2008
Posts: 2
d'oh! Brick wall

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.