<%@ Page Language="C#" AutoEventWireup="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Calendar1_SelectionChanged(object sender, System.EventArgs e)
{
ListItem li = new ListItem();
li.Text = Calendar1.SelectedDate.ToShortDateString();
BulletedList1.Items.Add(li);
Calendar1.SelectedDates.Clear();
SelectedDatesCollection dates = Calendar1.SelectedDates;
foreach (ListItem litem in BulletedList1.Items)
{
DateTime date = Convert.ToDateTime(litem.Text);
dates.Add(date);
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>How to select random dates in Calendar control</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:SlateBlue; font-style:italic;">
How to select random dates in Calendar control
</h2>
<hr width="500" align="left" color="SlateGray" />
<asp:BulletedList
ID="BulletedList1"
runat="server"
Visible="false"
>
</asp:BulletedList>
<asp:Calendar
ID="Calendar1"
runat="server"
NextPrevFormat="FullMonth"
ForeColor="WhiteSmoke"
SelectionMode="Day"
DayNameFormat="Full"
Font-Names="Book Antiqua"
Font-Size="Medium"
OnSelectionChanged="Calendar1_SelectionChanged"
>
<DayHeaderStyle
BackColor="OliveDrab"
/>
<DayStyle
BackColor="DarkOrange"
BorderColor="Orange"
BorderWidth="1"
Font-Bold="true"
Font-Italic="true"
Font-Size="Large"
/>
<NextPrevStyle
Font-Italic="true"
Font-Names="Arial CE"
/>
<OtherMonthDayStyle BackColor="OrangeRed" />
<SelectedDayStyle
BackColor="DarkSeaGreen"
BorderColor="OliveDrab"
/>
<TitleStyle
BackColor="MidnightBlue"
Height="36"
Font-Size="Large"
Font-Names="Courier New Baltic"
/>
</asp:Calendar>
</div>
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Calendar1_SelectionChanged(object sender, System.EventArgs e)
{
ListItem li = new ListItem();
li.Text = Calendar1.SelectedDate.ToShortDateString();
BulletedList1.Items.Add(li);
Calendar1.SelectedDates.Clear();
SelectedDatesCollection dates = Calendar1.SelectedDates;
foreach (ListItem litem in BulletedList1.Items)
{
DateTime date = Convert.ToDateTime(litem.Text);
dates.Add(date);
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>How to select random dates in Calendar control</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:SlateBlue; font-style:italic;">
How to select random dates in Calendar control
</h2>
<hr width="500" align="left" color="SlateGray" />
<asp:BulletedList
ID="BulletedList1"
runat="server"
Visible="false"
>
</asp:BulletedList>
<asp:Calendar
ID="Calendar1"
runat="server"
NextPrevFormat="FullMonth"
ForeColor="WhiteSmoke"
SelectionMode="Day"
DayNameFormat="Full"
Font-Names="Book Antiqua"
Font-Size="Medium"
OnSelectionChanged="Calendar1_SelectionChanged"
>
<DayHeaderStyle
BackColor="OliveDrab"
/>
<DayStyle
BackColor="DarkOrange"
BorderColor="Orange"
BorderWidth="1"
Font-Bold="true"
Font-Italic="true"
Font-Size="Large"
/>
<NextPrevStyle
Font-Italic="true"
Font-Names="Arial CE"
/>
<OtherMonthDayStyle BackColor="OrangeRed" />
<SelectedDayStyle
BackColor="DarkSeaGreen"
BorderColor="OliveDrab"
/>
<TitleStyle
BackColor="MidnightBlue"
Height="36"
Font-Size="Large"
Font-Names="Courier New Baltic"
/>
</asp:Calendar>
</div>
</form>
</body>
</html>
No comments:
Post a Comment