📄 calendar.aspx
字号:
<%@ Page Language="C#" Debug="true" %>
<%@ Import namespace="System.IO" %>
<html>
<head>
<title>Calendar Example</title>
<script language="C#" runat="server">
string ReadDate(DateTime date)
{
StreamReader reader;
try
{
reader = File.OpenText(Request.PhysicalApplicationPath
+ "\\lesson9\\" + date.ToLongDateString());
string s = reader.ReadToEnd();
reader.Close();
return s;
}
catch(FileNotFoundException e)
{
return "";
}
catch(Exception e)
{
Response.Write(e.ToString());
return e.ToString();
}
}
void WriteDate(DateTime date, string content)
{
StreamWriter writer;
try
{
writer = File.CreateText(Request.PhysicalApplicationPath
+ "\\lesson9\\" + date.ToLongDateString());
writer.Write(content);
writer.Close();
}
catch(Exception e)
{
Response.Write(e.ToString());
}
}
void Page_Load()
{
if(!IsPostBack)
{
calendar1.SelectedDate = DateTime.Now;
Label1.Text = calendar1.SelectedDate.ToLongDateString();
txtTodayTask.Text = ReadDate(calendar1.SelectedDate);
Session["LastDate"] = calendar1.SelectedDate;
}
}
void OnSelectionChanged(object sender, EventArgs arg)
{
WriteDate((DateTime)Session["LastDate"], txtTodayTask.Text);
Label1.Text = calendar1.SelectedDate.ToLongDateString();
txtTodayTask.Text = ReadDate(calendar1.SelectedDate);
Session["LastDate"] = calendar1.SelectedDate;
}
</script>
</head>
<body>
<h3>Calendar Example</h3>
<form id="form1" runat="server">
<asp:Calendar id="calendar1" runat="server"
SelectionMode="Day"
OnSelectionChanged="OnSelectionChanged" >
<SelectedDayStyle forecolor="Yellow" backcolor="Blue">
</SelectedDayStyle>
</asp:Calendar>
<hr/>
<asp:Label id="Label1" runat="server"/><br/>
<asp:TextBox id="txtTodayTask"
TextMode="Multiline" Columns="44"
Rows="5" runat="server" />
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -