使用 AJAX.NET & AjaxControlToolkit的PersianCalendar控件

分享于 

5分钟阅读

Web开发

  繁體

Sample Image - PersianCalendarControl.jpg

介绍

这是一个波斯日历网页自定义控件,具有 ASP.NET 2.0日历的完整功能。

在演示项目中,我使用了 AJAX.NET 和 AjaxControlToolkit ( http://ajax.asp.net/downloads/default.aspx?tabid=47 )。

要检索&设置日期,请使用" SelectedDatePersian"属性你也可以使用" SelectedDate"属性来检索所选日期,在基督 format.This 控件支持范围日期选择中。 要启用这里功能,必须将" SelectionMode"属性设置为" DayWeekMonth"或者" DayWeek",并用于检索,所选日期范围从" SelectedDates"属性。

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

要格式化选定的波斯日期,请使用" SelectedPersianDateFormat"。

PersianCalendar1.SelectedPersianDateFormat == 
 PersianDateStringType.LongReverse;

或者

PersianCalendar1.SelectedPersianDateFormat == PersianDateStringType.Short;

这里示例演示如何将 PersianCalendar 控件与 AJAX UpdatePanel 一起使用。

<%@PageLanguage="C#"AutoEventWireup="true"Codebehind="Default.aspx.cs"Inherits="AJAXEnabledWebApplication1._Default"%><%@RegisterAssembly="KingOf.Net.Web.UI.WebControls.PersianCalendar"Namespace="KingOf.Net.Web.UI.WebControls"TagPrefix="KingOfDotNet"%><%@RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="cc1"%><!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"><title>Untitled Page</title></head><body><formid="form1"runat="server"> Persian Calendar Web Control Compatible With Ajax.Net<br/><asp:TextBoxID="TextBox1"runat="server"AutoPostBack="True"></asp:TextBox><br/><asp:ScriptManagerID="ScriptManager1"runat="server"/><div><cc1:PopupControlExtenderID="PopupControlExtender1"runat="server"TargetControlID="TextBox1"PopupControlID="Panel1"Position="Bottom"></cc1:PopupControlExtender><asp:PanelID="Panel1"runat="server"CssClass="popupControl"><asp:UpdatePanelID="UpdatePanel1"runat="server"><ContentTemplate><center><KingOfDotNet:PersianCalendarID="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"><SelectedDayStyleBackColor="#CCCCFF"Font-Bold="True"/><TodayDayStyleBackColor="#FFCC66"ForeColor="White"/><SelectorStyleBackColor="#FFCC66"/><OtherMonthDayStyleForeColor="#CC9966"/><NextPrevStyleFont-Size="9pt"ForeColor="#FFFFCC"/><DayHeaderStyleBackColor="#FFCC66"Font-Bold="True"Height="1px"/><TitleStyleBackColor="#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
{
 publicpartialclass _Default : System.Web.UI.Page
 {
 protectedvoid Page_Load(object sender, EventArgs e)
 {
 }
 protectedvoid PersianCalendar1_SelectionChanged
 (object sender, EventArgs e)
 {
 PopupControlExtender1.Commit(PersianCalendar1.SelectedDatePersian);
 }
 }
}

相关文章