Export (0) Print
Expand All

MonthChangedEventArgs Class

Provides data for the VisibleMonthChanged event of a Calendar control.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

public class MonthChangedEventArgs
public class MonthChangedEventArgs
public class MonthChangedEventArgs

The VisibleMonthChanged event is raised when the user clicks the Calendar navigation controls to display the next or previous month.

For a list of initial property values for an instance of MonthChangedEventArgs, see the MonthChangedEventArgs constructor.

For more information about handling events, see Events and Delegates.

The following code example demonstrates how to specify and code a handler for the VisibleMonthChanged event that displays in a Label control whether the Calendar control has moved forward or backward one month.

<%@ 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="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>
   

System.Object
  System.Web.UI.WebControls.MonthChangedEventArgs

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft