The calendar control is one of the controls of .NET, powerful, is useful in many project development, which 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. Create a user control and pull the Calender control. The first step is to set up, this is required to make some adjustments to its related properties according to your needs. The picture below is the following interface attribute settings as follows:
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 = ((DayRendeventargs) e) .day; TableCell C = ((DayRendreventArgs) e). Cell;
// Initialize the current month's date array if (INTPREMONTH == 0) {INTPREMONTH = D.date.month; // Note: The first month we get in the first month when the calendar control is initialized, but the former one intCurrentMonth month month = intPreMonth 1; if (intCurrentMonth> 12) intCurrentMonth = 1; intNextMonth = intCurrentMonth 1; if (intNextMonth> 12) intNextMonth = 1; arrPreDays = getArrayDay (d.Date.Year, intPreMonth); // Received the date array of blogs from the previous month ArrcurrentDays = GetArrayDay (D.date.Year, INTCURRENTMONTH); // Get date array of blogs in the month arrnextDays = GetArrayDay (D.date.Year, IntnexTmonth); // Get next month There is a date array of blog} 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 literalcontrol (" D.date.day " D.date.day "