700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > 使用Calendar控件 并使用百度搜索的方式作为行事历的网路链结 制作日历

使用Calendar控件 并使用百度搜索的方式作为行事历的网路链结 制作日历

时间:2019-02-06 18:50:29

相关推荐

使用Calendar控件 并使用百度搜索的方式作为行事历的网路链结 制作日历

使用Calendar控件,并使用百度搜索的方式作为行事历的网路链结,制作日历

文章目录

使用Calendar控件,并使用百度搜索的方式作为行事历的网路链结,制作日历题目一、涉及的知识1.Calendar控件2.C#script二、解决方法1.运行截图2.代码实现

题目

请使用Calendar控件,新增与标示重要行事历日期,如:情人节、清明节、端午节、七夕、中元节、中秋节、教师节等日期。并使用百度搜索的方式作为行事历的网路链结(例如:/s?wd=情人节),如下图所示:。

一、涉及的知识

1.Calendar控件

学习资源 来源 菜鸟教程 Calendar控件

2.C#script

二、解决方法

1.运行截图

2.代码实现

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="2-Calendar.aspx.cs" Inherits="homework4._2_Calendar" %><!DOCTYPE html><html xmlns="/1999/xhtml"><head runat="server"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><title>2-Calendar日历</title></head><body><form id="form1" runat="server"><div><asp:Calendar ID="Calendar1" runat="server" DayNameFormat="Full" FirstDayOfWeek="Sunday" OnDayRender="Vacation"><WeekendDayStyle BackColor="#00ff00" /><DayHeaderStyle ForeColor="#0000ff" /><OtherMonthDayStyle ForeColor="#808080" /><TodayDayStyle ForeColor="#FF0000" /></asp:Calendar></div></form></body></html>

using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;namespace homework4{public partial class _2_Calendar : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e){}protected void Vacation(object sender, DayRenderEventArgs e){//定义节假日的Style vacationStyle = new Style();//创建节假日类的对象vacationStyle.BackColor = System.Drawing.Color.Yellow;//显示样式为黄色vacationStyle.BorderColor = System.Drawing.Color.Purple;//边框为紫色vacationStyle.BorderWidth = 3;//定义假期显示内容string Valentine = "情人节";//4月 4-14string Qingming = "清明节";//4-5string aHoliday = "劳动节";//5月 5-1string teen = "五四青年节";//5-4string mother = "母亲节";// 5-8string Dragon_Boat = "端午节";//6-3string Tanabata = "七夕节";//8-4string Hungry_Ghost = "中元节";//8-12string Mid_Autumn = "中秋节";//9-10string Teachers = "教师节";//9-10if (e.Day.Date == new DateTime(, 4, 5)){e.Cell.ApplyStyle(vacationStyle);//假期应用样式Label alabel = new Label();//创建标签alabel.Text = "<br>" + "<a href=/s?wd=清明节>" + Qingming + "</a>";e.Cell.Controls.Add(alabel);}if (e.Day.Date == new DateTime(, 4, 14)){e.Cell.ApplyStyle(vacationStyle);//假期应用样式Label alabel = new Label();//创建标签alabel.Text = "<br>" + "<a href=/s?wd=情人节>" + Valentine + "</a>";e.Cell.Controls.Add(alabel);}if (e.Day.Date == new DateTime(, 5, 1)){e.Cell.ApplyStyle(vacationStyle);//假期应用样式Label alabel = new Label();//创建标签alabel.Text = "<br>" + "<a href=/s?wd=劳动节>" + aHoliday + "</a>";e.Cell.Controls.Add(alabel);}if (e.Day.Date == new DateTime(, 5, 4)){e.Cell.ApplyStyle(vacationStyle);//假期应用样式Label alabel = new Label();//创建标签alabel.Text = "<br>" + "<a href=/s?wd=五四青年节>" + teen + "</a>";e.Cell.Controls.Add(alabel);}if (e.Day.Date == new DateTime(, 5, 8)){e.Cell.ApplyStyle(vacationStyle);//假期应用样式Label alabel = new Label();//创建标签alabel.Text = "<br>" + "<a href=/s?wd=母亲节>" + mother + "</a>";e.Cell.Controls.Add(alabel);}if (e.Day.Date == new DateTime(, 6, 3)){e.Cell.ApplyStyle(vacationStyle);//假期应用样式Label alabel = new Label();//创建标签alabel.Text = "<br>" + "<a href=/s?wd=端午节>" + Dragon_Boat + "</a>";e.Cell.Controls.Add(alabel);}if (e.Day.Date == new DateTime(, 8, 4)){e.Cell.ApplyStyle(vacationStyle);//假期应用样式Label alabel = new Label();//创建标签alabel.Text = "<br>" + "<a href=/s?wd=七夕节>" + Tanabata + "</a>";e.Cell.Controls.Add(alabel);}if (e.Day.Date == new DateTime(, 8, 12)){e.Cell.ApplyStyle(vacationStyle);//假期应用样式Label alabel = new Label();//创建标签alabel.Text = "<br>" + "<a href=/s?wd=中元节>" + Hungry_Ghost + "</a>";e.Cell.Controls.Add(alabel);}// string Mid_Autumn = "中秋节";//9-10// string Teachers = "教师节";//9-10if (e.Day.Date == new DateTime(, 9, 10)){e.Cell.ApplyStyle(vacationStyle);//假期应用样式Label alabel = new Label();//创建标签alabel.Text = "<br>" + "<a href=/s?wd=中秋节/教师节>" + Mid_Autumn + "</a>";e.Cell.Controls.Add(alabel);}}}}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。