Click here to Skip to main content
Licence CPOL
First Posted 28 Jan 2007
Views 68,774
Downloads 2,268
Bookmarked 40 times

PersianCalendar WebControl Using With AJAX.NET & AjaxControlToolkit

By | 15 Feb 2007 | Article
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.

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

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

PersianCalendar1.SelectedPersianDateFormat == 
                    PersianDateStringType.LongReverse;

or

PersianCalendar1.SelectedPersianDateFormat == PersianDateStringType.Short;

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

<%@ 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>

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)

About the Author

vahid_mardani

Web Developer

Iran (Islamic Republic Of) Iran (Islamic Republic Of)

Member

Python, PostgreSQL, Cherrypy, Apache, .Net , C#, Asp.net, .Net Remoting, Ajax, Controls, MVC, SOA, SOAP, Razor

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionVery nice Pinmembermasoudweb21:06 6 Aug '11  
AnswerRe: Very nice Pinmembervahid_mardani23:24 6 Aug '11  
GeneralMy vote of 5 PinmemberMember 790565223:00 7 May '11  
GeneralUse one calender for multiple textbox PinmemberfaraX_Xx23:31 21 Dec '10  
GeneralExcellent PinmemberKamyar5:29 21 Oct '10  
GeneralRe: Excellent Pinmembervahid_mardani6:19 25 Oct '10  
GeneralMy vote of 5 PinmemberKamyar5:26 21 Oct '10  
GeneralMy vote of 5 Pinmembersanam6410:45 28 Aug '10  
GeneralRe: My vote of 5 Pinmembervahid_mardani6:18 25 Oct '10  
Generalthis is brilliant piece of work Pinmemberkazim bhai0:59 18 Nov '08  
Questionhi i have e a little problem with this one PinmemberNika Asgari0:18 1 Sep '08  
AnswerRe: hi i have e a little problem with this one PinmemberNika Asgari18:23 1 Sep '08  
AnswerRe: hi i have e a little problem with this one Pinmembervahid_mardani11:10 2 Sep '08  
Generali have a problem PinmemberMember 335032220:23 4 Jun '08  
GeneralSuggestionُ PinmemberAbbas Sarraf1:21 19 Feb '08  
GeneralThanks PinmemberMember 25173029:06 11 Feb '08  
General[Message Removed] PinmemberMojtaba Vali20:41 9 Feb '08  
GeneralRe: YearPopup and Month popup Problem Pinmembervahid_mardani11:17 10 Feb '08  
GeneralConfiguration Error Pinmemberhassan azizi21:52 9 Nov '07  
AnswerRe: Configuration Error Pinmembervahid_mardani11:23 10 Feb '08  
GeneralBug with firefox and ie6 Pinmemberxollo5:08 24 Oct '07  
GeneralRe: Bug with firefox and ie6 Pinmembervahid_mardani11:30 10 Feb '08  
QuestionCompilation Problem PinmemberEhsanShemirani22:05 26 Sep '07  
Questionis your control client side? Pinmemberznarges8022:41 27 Aug '07  
GeneralRe: is your control client side? Pinmembervahid_mardani11:32 10 Feb '08  

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

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

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 15 Feb 2007
Article Copyright 2007 by vahid_mardani
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid