Tuesday, 15 January 2013

How to set VisibleDate property of asp:Calendar control

How to set VisibleDate property of asp:Calendar control

Calendar Web Server Control in ASP.NET

<h3>Calendar Control VisibleDate Property</h3>
        <asp:Calendar ID="Calendar1"  runat="server" 
            ToolTip="Calendar Control VisibleDate Style"
            ForeColor="#6600CC" Height="183px"
            ShowGridLines="True" Width="459px">
            <DayHeaderStyle BackColor="#66FF66" />
            <SelectedDayStyle BackColor="Red" />
            <TodayDayStyle BackColor="White" />

Note: This is the only property user can set at design time. Selected Date is not allowed at design time.  So coming to Visible date style, There is no Style for VisibleDate.  We need to set selected date ad VisibleDate(set set at design time), so that Selected day style will appear(Assuming SelectionMode is Day.

Page_Load  set SelectedDate as VisibleDate

protected void Page_Load(object sender, EventArgs e)
        Calendar1.SelectedDate = Calendar1.VisibleDate;

Protected  Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        Calendar1.SelectedDate = Calendar1.VisibleDate
End Sub

Here is the Output
VisibleDate Style

Tags:Calendar Web Server Control,Calendar Control,Calendar VisibleDate Property,Calendar Selected Date Style,asp.net webserver calendar control