By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,846 Members | 1,449 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,846 IT Pros & Developers. It's quick & easy.

can not select todays date with asp calendar within an update panel

P: 69
Hi guys,

I have an asp calendar control, text box, calendar icon, eraser icon all within an update panel. The calendar works fine, postbacks are handled without the flickering of the screen etc. my only problem is that i can not select today's date to display in the text box because by default, today's date is the selected date.

Expand|Select|Wrap|Line Numbers
  1. <asp:UpdatePanel ID="UpdatePanel_start" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
  2.                                     <ContentTemplate>
  3.                                 <asp:TextBox ID="startDateTB" runat="server" Enabled="False" style="font-family: Arial"></asp:TextBox>
  4.                                 <asp:ImageButton ID="startDateIB" runat="server" ImageUrl="~/Images/cal.gif" OnClick="startDateIB_Click" />&nbsp;
  5.                                 <asp:ImageButton ID="startErase" runat="server" ImageUrl="~/Images/erase.jpg" OnClick="startErase_Click" CausesValidation="False" />
  6.                                 <asp:Label ID="Label1" runat="server" ForeColor="Red" Text="*"></asp:Label><br />
  7.                                 <asp:Calendar ID="startCalendar" runat="server" BackColor="White" BorderColor="#999999"
  8.                                     CellPadding="4" DayNameFormat="Shortest" Font-Names="Verdana" Font-Size="8pt"
  9.                                     ForeColor="Black" Height="180px" OnSelectionChanged="startCalendar_SelectionChanged" 
  10.                                     Visible="False" Width="200px" style="position: relative" >
  11.                                     <SelectedDayStyle BackColor="#666666" Font-Bold="True" ForeColor="White" />
  12.                                     <TodayDayStyle BackColor="#CCCCCC" ForeColor="Black" />
  13.                                     <SelectorStyle BackColor="#CCCCCC" />
  14.                                     <WeekendDayStyle BackColor="#FFFFCC" />
  15.                                     <OtherMonthDayStyle ForeColor="Gray" />
  16.                                     <NextPrevStyle VerticalAlign="Bottom" />
  17.                                     <DayHeaderStyle BackColor="#CCCCCC" Font-Bold="True" Font-Size="7pt" />
  18.                                     <TitleStyle BackColor="#999999" BorderColor="Black" Font-Bold="True" />
  19.                                 </asp:Calendar>
  20.                                     </ContentTemplate>
  21.                                     <Triggers> 
  22.                                         <asp:AsyncPostBackTrigger ControlID="startDateIB" EventName="Click"/>
  23.                                         <asp:AsyncPostBackTrigger ControlID="startErase" EventName="Click" />
  24.                                     </Triggers>
  25.                                 </asp:UpdatePanel>
My selection changed code is as follows

Expand|Select|Wrap|Line Numbers
  1.  protected void startCalendar_SelectionChanged(object sender, EventArgs e)
  2.     {
  3.         startCalendar.Visible = false;
  4.         startDateTB.Text = startCalendar.SelectedDate.ToShortDateString();
  5.       }
my problem is that since the default date is today's date,when the user clicks on todays date in the calendar, the SelectionChanged event is never fired because the date was technically never changed so nothing happens.

Can anyone help me overcome this
Jul 3 '08 #1
Share this Question
Share on Google+
1 Reply

P: 69
sorry guys,

thanks anyway.

it is working
somehow i set the selected date to be todays date in page load.

Deleted it and it works perfectly

Jul 3 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.