Asp. NET program to implement the blog calendar

Source: Internet
Author: User
Tags array thread visual studio
Asp.net| Blog | program | Calendar Effect chart:

Front Page

<%@ Page language= "C #" codebehind= "WebForm1.aspx.cs" autoeventwireup= "false" inherits= "Blog_calendar. WebForm1 "%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name= "generator" content= "Microsoft Visual Studio. NET 7.1" >
<meta name= "Code_language" content= "C #" >
<meta name= "vs_defaultClientScript" content= "JavaScript" >
<meta name= "vs_targetschema" content= "http://schemas.microsoft.com/intellisense/ie5" >
</HEAD>
<body ms_positioning= "GridLayout" >
<form id= "Form1" method= "POST" runat= "Server" >
<asp:calendar id= "Calendar1" cellpadding= "2" width= "160px" titlestyle-backcolor= "#000000" bordercolor= "#aaaaaa"
Dayheaderstyle-backcolor= "#5e715e" othermonthdaystyle-forecolor= "#cccccc" daynameformat= "full"
runat= "Server" titlestyle-forecolor= "#ffffff" nextprevstyle-forecolor= "#ffffff" cellspacing= "1"
Weekenddaystyle-backcolor= "#eeeeee" dayheaderstyle-forecolor= "#ffffff" selectionmode= "None"
Todaydaystyle-bordercolor= "#5e715e" todaydaystyle-borderwidth= "1" todaydaystyle-font-bold= "true"
Todaydaystyle-forecolor= "#5e715e" >
<todaydaystyle font-bold= "True" borderwidth= "1px" forecolor= "#5E715E" bordercolor= "#5E715E" ></ Todaydaystyle>
<nextprevstyle forecolor= "White" ></NextPrevStyle>
<dayheaderstyle forecolor= "White" backcolor= "#404040" ></DayHeaderStyle>
<titlestyle forecolor= "white" backcolor= "Black" ></TitleStyle>
<weekenddaystyle backcolor= "Silver" ></WeekendDayStyle>
<othermonthdaystyle forecolor= "#CCCCCC" ></OtherMonthDayStyle>
</asp:calendar>
</form>
</body>
</HTML>

Background program:

Using System;
Using System.Collections;
Using System.ComponentModel;
Using System.Data;
Using System.Drawing;
Using System.Web;
Using System.Web.SessionState;
Using System.Web.UI;
Using System.Web.UI.WebControls;
Using System.Web.UI.HtmlControls;
Using System.Threading;
Using System.Globalization;
Using System.Data.SqlClient;

Namespace Blog_calendar
{
<summary>
Summary description of the WebForm1.
</summary>
public class WebForm1:System.Web.UI.Page
{
protected System.Web.UI.WebControls.Calendar Calendar1;
Private int[] arrcurrentdays,arrpredays,arrnextdays; Three variables are the current month, the previous January, and the next one months
private int intcurrentmonth,intpremonth,intnextmonth; Three integer arrays hold relative month date of blog

private void Page_Load (object sender, System.EventArgs e)
{
Place user code here to initialize page
}

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;
}

private void Calendar1_dayrender (object sender, System.Web.UI.WebControls.DayRenderEventArgs e)
{
The control occurs each day when it is created.
CalendarDay d = ((Dayrendereventargs) e). Day;
TableCell c = ((Dayrendereventargs) e). Cell;
Initializes an array of dates with blogs for the current month
if (intpremonth = 0)
{
Intpremonth = D.date.month; Note: The first month we get when the Calendar control is initialized is not the current month, but the month of the first one months
Response.Write (D.date.month.tostring ());
Intcurrentmonth = intpremonth+1;
if (intcurrentmonth>12)
intcurrentmonth=1;
Intnextmonth = intcurrentmonth+1;
if (Intnextmonth >12)
Intnextmonth = 1;
Arrpredays = Getarrayday (d.date.year,intpremonth); Get an array of dates with blogs for the first one months
Arrcurrentdays = Getarrayday (d.date.year,intcurrentmonth);//Get an array of dates with blogs for the month
Arrnextdays = Getarrayday (d.date.year,intnextmonth);//Get an array of dates for next month's blog
}

int j=0;

[1] [2] Next page



Related Article

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.