Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / web / ASP.NET

Anthem.PersianCalendar - .NET Persian Calendar WebControl

4.65/5 (18 votes)
12 Nov 2009CPOL1 min read 1   4.6K  
An Ajax PersianCalendar Control that looks like Original Calendar of .NET Framework
Anthem2005PlusPersianCalendar

PersianCalendarLogo.jpg

Introduction

As you know, unfortunately there is no suitable Persian Calendar Control that can implement AJAX functionality. So I decided to solve the problem in the easiest way.
Thanks to Anthem Open Source AJAX toolkit, I used it to develop my new Calendar.

Background

A .NET Calendar WebControl in fact is a Table Server Control. In each cell, there is a linkbutton control. So we can make our new Calendar with this Server Control. It’s easy to use and can fill some of our basic needs. One of these basic needs is Style. In a calendar, Styles of different parts are very important (e.g. the Style of Selected Date or Today or NextPrevMonthName and…).

Update

In the new version of Persian Calendar, we have two events:

  • SelectedDayChange
  • SelectedMonthChange

You can handle these events to do any action on date change or month change.

Using the Code

It’s very easy to use. It looks just like original Calendar. It has some extra properties like FarsiDateType that formats the output string in the SelectedFarsiDate property. This property returns the Farsi date of SelectedDate Property.

C#
protected void Button1_Click(object sender, EventArgs e)
{
this.ShowSelectedFarsiDate.Text = string.Format("{0}<p dir=rtl align=left>{1}</p>", 
	this.PersianCalendar1.SelectedDate.ToLongDateString(), 
	this.PersianCalendar1.SelectedFarsiDate);
this.ShowSelectedFarsiDate.UpdateAfterCallBack = true;
}

Points of Interest

During the development of this control, I was interested in Designer Attribute. I created a class that can handle AutoFormat Design-Time Service in this control. I hope this control can fit your needs too.

History

  • Version: 1.5.2 Of Anthem Ajax controls [With Events]
  • Version: 1.5.2 Of Anthem Ajax controls

License

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