Logo 
Search:

Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

How to get & set events for Calendar Control

  Asked By: Abbie    Date: Jun 20    Category: Asp.net    Views: 1333
  

I want to develope a desktop calendar for printing purpose but I
don't know htat how to set date for calendar control and if someone
changes month, how to change date in other 2 cal control at bottom.

Following is control i use.



Calendar.ascx

<%@ Control Language="VB" %>
<script runat="server">

' Insert user control code here
sub page_load
calendar2.SelectedDate= DateTime.Now.Addmonths(-1)
Calendar2.VisibleDate= DateTime.Now.Addmonths(-1)
calendar3.SelectedDate= DateTime.Now.Addmonths(1)
Calendar3.VisibleDate= DateTime.Now.Addmonths(1)
Calendar2.SelectedDate = Calendar1.SelectedDate
Calendar3.SelectedDate = Calendar1.SelectedDate
end sub
sub ChangeMonth(sender As Object, e As EventArgs)
calendar2.SelectedDate= Calendar1.SelectedDate.Addmonths(-
1)
Calendar2.SelectedDate = Date.Parse
(Calendar1.SelectedDate).AddMonths(-1)
calendar2.VisibleDate= Date.Parse
(Calendar1.SelectedDate).Addmonths(-1)
Calendar3.VisibleDate = Date.Parse
(Calendar1.SelectedDate).AddMonths(-1)
Calendar3.SelectedDate = Date.Parse
(Calendar1.SelectedDate)
end sub

</script>
<p>
<!-- Insert content here -->
<asp:Calendar id="Calendar1" ShowGridLines="True"
BorderColor="#FFCC66" Font-Names="Verdana" Font-Size="8pt"
Height="10.5in" ForeColor="#663399" Width="8in" BackColor="#FFFFCC"
BorderWidth="1px" VisibleMonthChanged="ChangeMonth" runat="server"
DayNameFormat="FirstLetter">
<TodayDayStyle forecolor="White"
backcolor="#FFCC66"></TodayDayStyle>
<SelectorStyle backcolor="#FFCC66"></SelectorStyle>
<DayStyle font-size="Large" font-names="Comic Sans MS"
horizontalalign="Left" verticalalign="Top"></DayStyle>
<NextPrevStyle font-size="9pt"
forecolor="#FFFFCC"></NextPrevStyle>
<DayHeaderStyle height="1px"
backcolor="#FFCC66"></DayHeaderStyle>
<SelectedDayStyle font-bold="True"
backcolor="#CCCCFF"></SelectedDayStyle>
<TitleStyle font-size="9pt" font-bold="True"
forecolor="#FFFFCC" backcolor="#990000"></TitleStyle>
<OtherMonthDayStyle forecolor="#CC9966"></OtherMonthDayStyle>
</asp:Calendar>
</p>
<p>
<table width="100%">
<tbody>
<tr>
<td align="left">
<asp:Calendar id="Calendar2" BorderColor="White"
Font-Names="Verdana" Font-Size="9pt" Height="121px" ForeColor="Black"
Width="175px" BackColor="White" BorderWidth="1px" runat="server"
ShowNextPrevMonth="False" SelectionMode="None"
NextPrevFormat="ShortMonth">
<TodayDayStyle
backcolor="#CCCCCC"></TodayDayStyle>
<NextPrevStyle font-size="8pt" font-
bold="True" forecolor="#333333"
verticalalign="Bottom"></NextPrevStyle>
<DayHeaderStyle font-size="8pt" font-
bold="True"></DayHeaderStyle>
<SelectedDayStyle forecolor="White"
backcolor="#333399"></SelectedDayStyle>
<TitleStyle font-size="12pt" font-bold="True"
borderwidth="1px" forecolor="#333399" bordercolor="Black"
backcolor="White"></TitleStyle>
<OtherMonthDayStyle
forecolor="#999999"></OtherMonthDayStyle>
</asp:Calendar>
</td>
<td align="right">
<asp:Calendar id="Calendar3" BorderColor="White"
Font-Names="Verdana" Font-Size="9pt" Height="121px" ForeColor="Black"
Width="175px" BackColor="White" BorderWidth="1px" runat="server"
ShowNextPrevMonth="False" SelectionMode="None"
NextPrevFormat="ShortMonth">
<TodayDayStyle
backcolor="#CCCCCC"></TodayDayStyle>
<NextPrevStyle font-size="8pt" font-
bold="True" forecolor="#333333"
verticalalign="Bottom"></NextPrevStyle>
<DayHeaderStyle font-size="8pt" font-
bold="True"></DayHeaderStyle>
<SelectedDayStyle forecolor="White"
backcolor="#333399"></SelectedDayStyle>
<TitleStyle font-size="12pt" font-bold="True"
borderwidth="1px" forecolor="#333399" bordercolor="Black"
backcolor="White"></TitleStyle>
<OtherMonthDayStyle
forecolor="#999999"></OtherMonthDayStyle>
</asp:Calendar>
</td>
</tr>
</tbody>
</table>
</p>

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on How to get & set events for Calendar Control Or get search suggestion and latest updates.




Tagged: