Calender Control Using Ajax

Here i am posting code for calender control using ajax, in which we can select by day, by week and by month.

The code is as shown or you can get the attached file for the project


<%@ Page Language="C#" %>

<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %>



<script runat="server">

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
_cal.SelectionMode = CalendarSelectionMode.None;
}
}

protected void _cal_SelectionChanged(object sender, EventArgs e)
{
_message.Text = "You have selectecd : ";
foreach (DateTime t in _cal.SelectedDates)
{
_message.Text += "<br>"+t.Date.ToShortDateString();
}

}

protected void _none_Click(object sender, EventArgs e)
{
_cal.SelectionMode = CalendarSelectionMode.None;
}

protected void _day_Click(object sender, EventArgs e)
{
_cal.SelectionMode = CalendarSelectionMode.Day;
}

protected void _week_Click(object sender, EventArgs e)
{
_cal.SelectionMode = CalendarSelectionMode.DayWeek;
}

protected void _month_Click(object sender, EventArgs e)
{
_cal.SelectionMode = CalendarSelectionMode.DayWeekMonth;
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">

<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<br />
<br />
<asp:UpdatePanel ID = "updt" runat ="server">
<ContentTemplate>
<table style="width: 382px">
<tr>
<td rowspan=5>
<asp:Calendar ID="_cal" runat="server" OnSelectionChanged="_cal_SelectionChanged" />
</td>
<td style="width: 207px">
 Select By</td>
</tr>
<tr>
<td style="width: 207px">
<asp:Button ID="_none" Text="None" runat="server" OnClick="_none_Click" Width="51px" /></td>
</tr>
<tr>
<td style="width: 207px">
<asp:Button ID="_day" Text="Day" runat="server" OnClick="_day_Click" Width="51px" />
</td>
</tr>
<tr>
<td style="width: 207px">
<asp:Button ID="_week" Text="Week" runat="server" OnClick="_week_Click" Width="53px" />
</td>
</tr>
<tr>
<td style="width: 207px">
<asp:Button ID="_month" Text="Month" runat="server" OnClick="_month_Click" />
</td>
</tr>
</table>
<hr />
<asp:Label ID="_message" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" Height="333px" ImageUrl="~/loading.gif" Width="394px" />

</ProgressTemplate>
</asp:UpdateProgress>
 <br />
</div>

</form>
</body>
</html>


Attachments

  • Calender Control Using Ajax (29176-13910-AJAXEnabledWebSite1.rar)
  • Comments

    Author: Mrs. Meetu Choudhary Nanda11 Jul 2009 Member Level: Gold   Points : 2

    Hi Apul Vyas,

    I have modified your resource and approving it. but it would be better that you should be careful in providing the contents of the articles. only attachments are not considered a good article.

    Hope you understand this and help us in future. by posting well formatted and good articles.


    ++
    Thanks and Regards.
    Meetu Choudhary.
    Site Coordinator.



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: