The Calendar control is one of the. NET-enabled controls that are powerful and useful in many project development, and are essential for blogging systems. Longitudinal is good Jade also still need to carve, in order to make it more beautiful and practical, we also need to develop it two times.
Create a new user control and pull the calender control in. The first step is the appearance setting, which, depending on your needs, just makes some adjustments to its related properties. It's my adjusted interface.
The properties are set as follows:
The second step is to adjust the internal functions, which are mainly focused on the processing of the following two events.
PreRender: Occurs when a server control is about to be rendered to the Page object it contains.
DayRender: Occurs when each day is created in the control hierarchy for the Calendar control.
Define three integer variables and integer arrays first
Private int[] arrcurrentdays,arrpredays,arrnextdays; Three variables are the current month, the previous January, and the next month private int intcurrentmonth,intpremonth,intnextmonth; Three integer array holds the date of the blog relative to the month protected System.Web.UI.WebControls.Calendar Calendar1; And this is our Calendar control.
2. Below I will give the source of these two events separately, and explain the functions it implements below, if you do not understand, you can see the following instructions
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[]{"Day", "one", "two", "three", "four", "five", "six"}; CiNew.DateTimeFormat.FirstDayOfWeek = DayOfWeek.Sunday; Threadcurrent.currentculture = cinew;}
The above code changes the display of the week name. You can change the name display by simply changing the value of the character array.
DayRender
private void Calendar1_dayrender (object sender, System.Web.UI.WebControls.DayRenderEventArgs e) {//The control occurs every day when it is created. CalendarDay d = ((Dayrendereventargs) e). Day; TableCell C = ((Dayrendereventargs) e). Cell;}