Calendar.VisibleMonthChanged 事件
当用户单击标题标头上的下个月或上个月导航控件时发生。
**命名空间:**System.Web.UI.WebControls
**程序集:**System.Web(在 system.web.dll 中)
语法
声明
Public Event VisibleMonthChanged As MonthChangedEventHandler
用法
Dim instance As Calendar
Dim handler As MonthChangedEventHandler
AddHandler instance.VisibleMonthChanged, handler
public event MonthChangedEventHandler VisibleMonthChanged
public:
event MonthChangedEventHandler^ VisibleMonthChanged {
void add (MonthChangedEventHandler^ value);
void remove (MonthChangedEventHandler^ value);
}
/** @event */
public void add_VisibleMonthChanged (MonthChangedEventHandler value)
/** @event */
public void remove_VisibleMonthChanged (MonthChangedEventHandler value)
JScript 支持使用事件,但不支持进行新的声明。
备注
当用户单击标题标头上的下个月或上个月导航元素时引发此事件。
有关处理事件的更多信息,请参见 事件和委托。
主题 | 位置 |
---|---|
如何:在 Calendar Web 服务器控件中控制月份定位 | 在 Visual Studio 中生成 ASP .NET Web 应用程序 |
如何:在 Calendar Web 服务器控件中控制月份定位 | 在 Visual Studio 中生成 ASP .NET Web 应用程序 |
如何:在 Calendar Web 服务器控件中控制月份定位 | 生成 ASP .NET Web 应用程序 |
示例
下面的代码示例演示如何为 VisibleMonthChanged 事件指定和编写处理程序,以显示 Calendar 控件是否向前或向后移了一个月。
<%@ Page Language="VB" AutoEventWireup="True" %>
<html>
<head>
<script runat="server">
Sub MonthChange(sender As Object, e As MonthChangedEventArgs)
If e.NewDate.Month > e.PreviousDate.Month Then
Message.Text = "You moved forward one month."
Else
Message.Text = "You moved backwards one month."
End If
End Sub
</script>
</head>
<body>
<form runat="server">
<h3> Calendar VisibleMonthChanged Example </h3>
Select a different month on the calendar.
<br><br>
<asp:Calendar id="Calendar1" runat="server"
OnVisibleMonthChanged="MonthChange">
<WeekendDayStyle BackColor="gray">
</WeekendDayStyle>
</asp:Calendar>
<hr>
<table border="1">
<tr bgcolor="Silver">
<th>
Month navigation direction
</th>
</tr>
<tr>
<td>
<asp:Label id="Message"
Text="Starting Month."
runat="server"/>
</td>
</tr>
</table>
</form>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="True" %>
<html>
<head>
<script runat="server">
void MonthChange(Object sender, MonthChangedEventArgs e)
{
if (e.NewDate.Month > e.PreviousDate.Month)
{
Message.Text = "You moved forward one month.";
}
else
{
Message.Text = "You moved backwards one month.";
}
}
</script>
</head>
<body>
<form runat="server">
<h3> Calendar VisibleMonthChanged Example </h3>
Select a different month on the calendar.
<br><br>
<asp:Calendar id="Calendar1" runat="server"
OnVisibleMonthChanged="MonthChange">
<WeekendDayStyle BackColor="gray">
</WeekendDayStyle>
</asp:Calendar>
<hr>
<table border="1">
<tr bgcolor="Silver">
<th>
Month navigation direction
</th>
</tr>
<tr>
<td>
<asp:Label id="Message"
Text="Starting month."
runat="server"/>
</td>
</tr>
</table>
</form>
</body>
</html>
<%@ Page Language="VB" AutoEventWireup="True" %>
<html>
<head>
<script runat="server">
Sub MonthChange(sender As Object, e As MonthChangedEventArgs)
If e.NewDate.Month > e.PreviousDate.Month Then
Message.Text = "You moved forward one month."
Else
Message.Text = "You moved backwards one month."
End If
End Sub
Sub Page_Load(sender As Object, e As EventArgs)
' Manually register the event-handling method for the
' VisibleMonthChanged event of the Calendar control.
AddHandler Calendar1.VisibleMonthChanged, AddressOf MonthChange
End Sub
</script>
</head>
<body>
<form runat="server">
<h3> Calendar VisibleMonthChanged Example </h3>
Select a different month on the calendar.
<br><br>
<asp:Calendar id="Calendar1" runat="server">
<WeekendDayStyle BackColor="gray">
</WeekendDayStyle>
</asp:Calendar>
<hr>
<table border="1">
<tr bgcolor="Silver">
<th>
Month navigation direction
</th>
</tr>
<tr>
<td>
<asp:Label id="Message"
Text="Starting Month."
runat="server"/>
</td>
</tr>
</table>
</form>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="True" %>
<html>
<head>
<script runat="server">
void MonthChange(Object sender, MonthChangedEventArgs e)
{
if (e.NewDate.Month > e.PreviousDate.Month)
{
Message.Text = "You moved forward one month.";
}
else
{
Message.Text = "You moved backwards one month.";
}
}
void Page_Load(Object sender, EventArgs e)
{
// Manually register the event-handling method for the
// VisibleMonthChanged event of the Calendar control.
Calendar1.VisibleMonthChanged +=
new MonthChangedEventHandler(this.MonthChange);
}
</script>
</head>
<body>
<form runat="server">
<h3> Calendar VisibleMonthChanged Example </h3>
Select a different month on the calendar.
<br><br>
<asp:Calendar id="Calendar1" runat="server">
<WeekendDayStyle BackColor="gray">
</WeekendDayStyle>
</asp:Calendar>
<hr>
<table border="1">
<tr bgcolor="Silver">
<th>
Month navigation direction
</th>
</tr>
<tr>
<td>
<asp:Label id="Message"
Text="Starting month."
runat="server"/>
</td>
</tr>
</table>
</form>
</body>
</html>
平台
Windows 98、Windows 2000 SP4、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition
.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求。
版本信息
.NET Framework
受以下版本支持:2.0、1.1、1.0
请参见
参考
Calendar 类
Calendar 成员
System.Web.UI.WebControls 命名空间
OnVisibleMonthChanged