⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 calendarschedule.aspx

📁 asp.net技术内幕的书配源码
💻 ASPX
字号:
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Runtime.Serialization" %>
<%@ Import Namespace="System.Runtime.Serialization.Formatters.Binary" %>
<%@ Import Namespace="System.Drawing" %>

<Script Runat="Server">

Dim arrCalendar( 13, 32 ) As String

' Get schedule from cache or disk
Sub Page_Load
  Dim strmFileStream As FileStream
  Dim fmtrBinaryFormatter As BinaryFormatter

  If Cache( "arrCalendar" ) Is Nothing Then
    If File.Exists( "c:\schedule.bin" ) Then
      strmFileStream = _
        New FileStream( "c:\schedule.bin", FileMode.Open )
      fmtrBinaryFormatter = New BinaryFormatter
      arrCalendar = _
        CType( fmtrBinaryFormatter.Deserialize( strmFileStream ), Array )
      strmFileStream.Close()
      Cache( "arrCalendar" ) = arrCalendar
    End If
  Else
    arrCalendar = Cache( "arrCalendar" )
  End If
End Sub

' Save schedule to file
Sub btnSave_Click( s As Object, e As EventArgs )
  Dim dtmDate As DateTime
  Dim strmFileStream As FileStream
  Dim fmtrBinaryFormatter As BinaryFormatter

  dtmDate = calSchedule.SelectedDate
  arrCalendar( dtmDate.Month, dtmDate.Day ) = txtNotes.Text
  strmFileStream = _
    New FileStream( "c:\schedule.bin", FileMode.Create )
  fmtrBinaryFormatter = New BinaryFormatter
  fmtrBinaryFormatter.Serialize( strmFileStream, arrCalendar )
  strmFileStream.Close()
  Cache( "arrCalendar" ) = arrCalendar
End Sub

' Pick a date
Sub Calendar_SelectionChanged( s As Object, e As EventArgs )
  Dim dtmDate As DateTime

  dtmDate = calSchedule.SelectedDate
  txtNotes.Text = arrCalendar( dtmDate.Month, dtmDate.Day )
End Sub

' Display each calendar day
Sub Calendar_RenderDay( s As Object, e As DayRenderEventArgs )
  Dim dtmDate As DateTime
  Dim ctlCell As TableCell

  dtmDate = e.Day.Date
  ctlCell = e.Cell
  If arrCalendar( dtmDate.Month, dtmDate.Day ) <> "" Then
    ctlCell.BackColor = Color.FromName( "Orange" )
  End If
End Sub

</Script>

<html>
<head><title>CalendarSchedule.aspx</title></head>
<body>

<form Runat="Server">

<asp:Calendar
  id="calSchedule"
  Width="100%"
  ShowGridLines="True"
  OnSelectionChanged="Calendar_SelectionChanged"
  OnDayRender="Calendar_RenderDay"
  Runat="Server" />

<p>
<asp:TextBox
  id="txtNotes"
  TextMode="MultiLIne"
  Columns="50"
  Rows="10"
  Runat="Server" />

<p>
<asp:Button
  id="btnSave"
  Text="Save Changes"
  OnClick="btnSave_Click"
  Runat="Server" />

</form>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -