ASP. NET Calendar Control usage

Source: Internet
Author: User

The ASP. NET Calendar is a Microsoft-brought calendaring control that, in addition to the simple display of datetime, can bind some required events. The Calendar_dayrender event is the way to load all the time dates, using this method to add the event you need on each calendar day, and write a corresponding pragmatic caseprotected voidCalendar1_dayrender (Objectsender, Dayrendereventargs e) {///when the date is not the current month, the number of days is removed (that is, the panel showing the date this month does not show the last month or the next month's extra date)        if(e.day.isothermonth) {e.cell.controls.clear (); return; }                                  //Add the JS ononmouseover event e.cell.attributes["onmouseover"] = "Mouseov ()" to each current date cell;                  ///add a class style to the current date only            if(E.day.date.tostring ("YYYY/MM/DD") = = DateTime.Now.ToString ("YYYY/MM/DD"))            {//today is the name of the stylee.cell.attributes["class"] ="Today"; }} and another is the Calendar_prerender event, this event I used to do the regional date automatic change, such as you want the English calendar as followsprotected voidCalendar1_prerender (Objectsender, System.EventArgs e) {System.Globalization.CultureInfo MyInfo=NewSystem.Globalization.CultureInfo ("en -US",false); System.Threading.Thread.CurrentThread.CurrentCulture=MyInfo; If it is in Chinese, the above en-us Change to zh-cn in Calendar_prerender can also define some other properties, forexample name of the weekPrivate voidCalendar1_prerender (Objectsender, System.EventArgs e) {Thread threadcurrent=Thread.CurrentThread; CultureInfo cinew=(CultureInfo) ThreadCurrent.CurrentCulture.Clone (); CiNew.DateTimeFormat.DayNames=New string[]{"Day","a","two","three","Four","Five","Six"}; CiNew.DateTimeFormat.FirstDayOfWeek=dayofweek.sunday; Threadcurrent.currentculture=cinew;} 

ASP. NET Calendar Control usage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.