Create a personal calendar control for your blog

xiaoxiao2021-03-06  16

The calendar is one of the controls of the DOTNET, which is powerful and is useful in many project development. It is essential for the Blog system. It still needs to be carved in a good jade, in order to make it more beautiful and practical, we also need to develop it secondary. The first step is to set up, this is required to make some adjustments to its related properties according to your needs.

Property is set as follows: the second step is to adjust the internal functions of this job Mainly concentrated on the processing of the following two events. Prerender: When the server control will be present to the PAGE object included. Dayrender: When the Calendar control is created every day in the control hierarchy.

First define three integer variables and integer array private int [] arrcurrentdays, arrpredays, arrnextdays; // three variables are the current month, the first month, and the next month private int INTCURRENTMONTH, INTPREMONTMONTMONTH, INTNEXTMONTH; // three A integer array stores a blog date protected system.web.ui.webcontrols.calendar calendar1; // This is our calendar control 2. I will give the source code of these events, and its function will be explained below to achieve, if you do not understand, the following explanation can look PreRender private void Calendar1_PreRender (object sender, System.EventArgs e) {Thread threadCurrent = Thread.CurrentThread; CultureInfo ciNew = (CultureInfo) threadCurrent.CurrentCulture. Clone (); cinew.datetimeformat.daynames = new string [] {"Japan", "One", "Second", "Three", "Four", "Five", "Six"}; cinew.datetimeformat.firstdayofweek = Dayofweek.sunday; threadcurrent.currentculture = cinew;} The above code changed the display of the weeks. You can change your name to display only if you want to change the value of the character array. DayRender Private Void Calendar1_dayrender (Object Sender, System.DayrenderEventArgs E) {// This control occurs every day.

Calendarday d = ((DayRendreventargs) e) .day; TableCell C = ((DayRendreventargs) e) .Cell; // Initialize the current month's date array if (intPRemonth == 0) {INTPREMONTH = D.DATE.MONTH; // Note: When the calendar control is initialized, our first month is not the current month, but the month INTCURRENTMONTH = INTPREMONTH 1 for the previous month; IF (intCurrentMonth> 12) INTCURRENTMONTH = 1; intnextMonth = IntCurrentMonth 1; IF (INTNEXTMONTH> 12) INTNEXTMONTH = 1; arrredays = getArrayDay (D.date.Year, INTPREMONTH); // Get the previous month's date array arrcurrentDays = GetArrayDay (D.date.Year, IntCurrentMonth); // Get the month There is a date array of blog, arrnextday = getArrayDay (D.date.Year, INTNEXTMONTH); // Get date arrays of blog next month} int J = 0; if (D.date.Month.equals (intPremonth)) {while (! arrpredays [j] .Equals (0)) {if (D.date.Day.equals (arrpredays [j])) {c.controls.clear (); c.controls.add (New LitralControl (" D.date.day "" ));} J ;}} else if (d.date.month.equals (intcurr EntMonth)) {while (! arrcurrentdays [j] .Equals (0)) {if (D.date.Day.equals (arrcurrentdays [j]) {c.controls.clear (); c.controls.add (new LITERALCONTROL ("" D.DATE.DAY " "));} J ;

转载请注明原文地址:https://www.9cbs.com/read-45601.html

New Post(0)