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.
My selection changed code is as follows
my problem is that since the default date is today's date,when the user clicks on todays date in the calendar, the SelectionChange d event is never fired because the date was technically never changed so nothing happens.
Can anyone help me overcome this
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.
Code:
<asp:UpdatePanel ID="UpdatePanel_start" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
<ContentTemplate>
<asp:TextBox ID="startDateTB" runat="server" Enabled="False" style="font-family: Arial"></asp:TextBox>
<asp:ImageButton ID="startDateIB" runat="server" ImageUrl="~/Images/cal.gif" OnClick="startDateIB_Click" />
<asp:ImageButton ID="startErase" runat="server" ImageUrl="~/Images/erase.jpg" OnClick="startErase_Click" CausesValidation="False" />
<asp:Label ID="Label1" runat="server" ForeColor="Red" Text="*"></asp:Label><br />
<asp:Calendar ID="startCalendar" runat="server" BackColor="White" BorderColor="#999999"
CellPadding="4" DayNameFormat="Shortest" Font-Names="Verdana" Font-Size="8pt"
ForeColor="Black" Height="180px" OnSelectionChanged="startCalendar_SelectionChanged"
Visible="False" Width="200px" style="position: relative" >
<SelectedDayStyle BackColor="#666666" Font-Bold="True" ForeColor="White" />
<TodayDayStyle BackColor="#CCCCCC" ForeColor="Black" />
<SelectorStyle BackColor="#CCCCCC" />
<WeekendDayStyle BackColor="#FFFFCC" />
<OtherMonthDayStyle ForeColor="Gray" />
<NextPrevStyle VerticalAlign="Bottom" />
<DayHeaderStyle BackColor="#CCCCCC" Font-Bold="True" Font-Size="7pt" />
<TitleStyle BackColor="#999999" BorderColor="Black" Font-Bold="True" />
</asp:Calendar>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="startDateIB" EventName="Click"/>
<asp:AsyncPostBackTrigger ControlID="startErase" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
Code:
protected void startCalendar_SelectionChanged(object sender, EventArgs e)
{
startCalendar.Visible = false;
startDateTB.Text = startCalendar.SelectedDate.ToShortDateString();
}
Can anyone help me overcome this
Comment