Click here to Skip to main content
15,884,425 members
Articles / Web Development / ASP.NET
Article

PersianCalendar WebControl Using With AJAX.NET & AjaxControlToolkit

Rate me:
Please Sign up or sign in to vote.
4.80/5 (29 votes)
15 Feb 2007CPOL 122.2K   4.8K   42   49
This is a Persian web calendar with full features like ASP.NET 2.0 Calendar Control

Sample Image - PersianCalendarControl.jpg

Introduction

This is a Persian calendar Web Custom control with full features like ASP.NET 2.0 Calendar.

In the demo project, I have used AJAX.NET and AjaxControlToolkit(http://ajax.asp.net/downloads/default.aspx?tabid=47).

For retrieving & setting the Persian date, use "SelectedDatePersian" Properties.You can also use "SelectedDate" Properties for retrieving the selected date in Christ format.This control supports range date selection. For enabling this feature, you must set "SelectionMode" properties to "DayWeekMonth" or "DayWeek" and for retrieving, selected dates range from "SelectedDates" Properties.

C#
PersianCalendar1.SelectionMode = CalendarSelectionMode.DayWeekMonth;
List<DateTime> selectedDates = 
    (List<DateTime>)PersianCalendar1.SelectedDates.GetEnumerator();

For formatting the selected Persian date, use "SelectedPersianDateFormat".

C#
PersianCalendar1.SelectedPersianDateFormat == 
                    PersianDateStringType.LongReverse;

or

C#
PersianCalendar1.SelectedPersianDateFormat == PersianDateStringType.Short;

This example demonstrates how to use the PersianCalendar Control with AJAX UpdatePanel.

ASP.NET
<%@ Page Language="C#" AutoEventWireup="true" Codebehind="Default.aspx.cs" 
            Inherits="AJAXEnabledWebApplication1._Default" %>
<%@ Register Assembly="KingOf.Net.Web.UI.WebControls.PersianCalendar" 
    Namespace="KingOf.Net.Web.UI.WebControls" TagPrefix="KingOfDotNet" %>
<%@ Register Assembly="AjaxControlToolkit" 
    Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
  <form id="form1" runat="server">
      Persian Calendar Web Control Compatible With Ajax.Net<br />
      <asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True">
    </asp:TextBox><br />
      <asp:ScriptManager ID="ScriptManager1" runat="server" />
      <div>
          <cc1:PopupControlExtender ID="PopupControlExtender1" 
        runat="server" TargetControlID="TextBox1"
                PopupControlID="Panel1" Position="Bottom">
          </cc1:PopupControlExtender>
          <asp:Panel ID="Panel1" runat="server" CssClass="popupControl">
              <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                  <ContentTemplate>
                      <center>
                          <KingOfDotNet:PersianCalendar ID="PersianCalendar1" 
                        runat="server" BackColor="#FFFFCC"
                              BorderColor="#FFCC66" BorderWidth="1px" 
                        DayNameFormat="Shortest" Font-Names="Verdana"
                              Font-Size="8pt" ForeColor="#663399" 
                        Height="200px" OnSelectionChanged=
                            "PersianCalendar1_SelectionChanged"
                              SelectedDate="2000-01-01" ShowGridLines="True" 
                            VisibleDate="2000-01-01" Width="220px"
                              SelectedPersianDateFormat="Long">
                              <SelectedDayStyle BackColor="#CCCCFF" 
                                Font-Bold="True" />
                              <TodayDayStyle BackColor="#FFCC66" 
                                ForeColor="White" />
                              <SelectorStyle BackColor="#FFCC66" />
                              <OtherMonthDayStyle ForeColor="#CC9966" />
                              <NextPrevStyle Font-Size="9pt" 
                                ForeColor="#FFFFCC" />
                              <DayHeaderStyle BackColor="#FFCC66" 
                            Font-Bold="True" Height="1px" />
                              <TitleStyle BackColor="#990000" 
                            Font-Bold="True" Font-Size="9pt" 
                            ForeColor="#FFFFCC" />
                          </KingOfDotNet:PersianCalendar>
                          &nbsp;
                      </center>
                  </ContentTemplate>
              </asp:UpdatePanel>
          </asp:Panel>
      </div>
  </form>
</body>
</html>

C#
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Globalization;
using KingOf.Net.Web.UI.WebControls;

namespace AJAXEnabledWebApplication1
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void PersianCalendar1_SelectionChanged
                                (object sender, EventArgs e)
        {
            PopupControlExtender1.Commit(PersianCalendar1.SelectedDatePersian);
        }
    }
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Iran (Islamic Republic of) Iran (Islamic Republic of)
Python, PostgreSQL, Cherrypy, Apache, .Net , C#, Asp.net, .Net Remoting, Ajax, Controls, MVC, SOA, SOAP, Razor

Comments and Discussions

 
GeneralBug with firefox and ie6 Pin
xollo24-Oct-07 5:08
xollo24-Oct-07 5:08 
GeneralRe: Bug with firefox and ie6 Pin
vahid_mardani10-Feb-08 11:30
vahid_mardani10-Feb-08 11:30 
QuestionCompilation Problem Pin
EhsanShemirani26-Sep-07 22:05
EhsanShemirani26-Sep-07 22:05 
Questionis your control client side? Pin
znarges8027-Aug-07 22:41
znarges8027-Aug-07 22:41 
GeneralRe: is your control client side? Pin
vahid_mardani10-Feb-08 11:32
vahid_mardani10-Feb-08 11:32 
Generalanother year Pin
maxpayn21-Aug-07 0:35
maxpayn21-Aug-07 0:35 
Questionhow change calendar js function Pin
pmapc868-Jul-07 23:28
pmapc868-Jul-07 23:28 
AnswerRe: how change calendar js function Pin
vahid_mardani10-Jul-07 13:39
vahid_mardani10-Jul-07 13:39 
Generalmy problems Pin
fa_20646-Mar-07 21:15
fa_20646-Mar-07 21:15 
GeneralGood Job Pin
Ahmad Asgharzadeh1-Mar-07 11:04
Ahmad Asgharzadeh1-Mar-07 11:04 
GeneralRe: Good Job Pin
vahid_mardani1-Mar-07 21:19
vahid_mardani1-Mar-07 21:19 
Generalnew feature Pin
Yahyaee20-Feb-07 21:33
Yahyaee20-Feb-07 21:33 
AnswerRe: new feature(already have this feature) Pin
vahid_mardani20-Feb-07 23:18
vahid_mardani20-Feb-07 23:18 
GeneralAbout Persian Calendar Pin
Afsoon13-Feb-07 21:29
Afsoon13-Feb-07 21:29 
GeneralRe: About Persian Calendar Pin
vahid_mardani13-Feb-07 21:58
vahid_mardani13-Feb-07 21:58 
GeneralRe: About Persian Calendar Pin
Afsoon14-Feb-07 20:21
Afsoon14-Feb-07 20:21 
AnswerRe: Persian Calendar Bug Fixed Pin
vahid_mardani15-Feb-07 7:28
vahid_mardani15-Feb-07 7:28 
GeneralRe: Persian Calendar Bug Fixed Pin
arash_cce10-Jul-07 4:26
arash_cce10-Jul-07 4:26 
GeneralRe: Persian Calendar Bug Fixed Pin
vahid_mardani10-Jul-07 13:15
vahid_mardani10-Jul-07 13:15 
GeneralKingOf.NET Pin
amirghz0729-Jan-07 8:50
amirghz0729-Jan-07 8:50 
GeneralThanks Pin
babakzawari29-Jan-07 0:39
babakzawari29-Jan-07 0:39 
GeneralRe: Thanks Pin
vahid_mardani29-Jan-07 0:52
vahid_mardani29-Jan-07 0:52 
GeneralRe: Thanks Pin
Majid Shahabfar29-Jan-07 6:19
Majid Shahabfar29-Jan-07 6:19 
GeneralRe: Thanks Pin
vahid_mardani29-Jan-07 6:29
vahid_mardani29-Jan-07 6:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.