Calendar.DayRender イベントとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > Calendar.DayRender イベントの意味・解説 

Calendar.DayRender イベント

各日付が Calendar コントロールコントロール階層作成される発生します

名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Event DayRender As
 DayRenderEventHandler
Dim instance As Calendar
Dim handler As DayRenderEventHandler

AddHandler instance.DayRender, handler
public event DayRenderEventHandler DayRender
public:
event DayRenderEventHandler^ DayRender {
    void add (DayRenderEventHandler^ value);
    void remove (DayRenderEventHandler^ value);
}
/** @event */
public void add_DayRender (DayRenderEventHandler
 value)

/** @event */
public void remove_DayRender (DayRenderEventHandler
 value)
JScript では、イベント使用できますが、新規に宣言することはできません。
解説解説

このイベントは、各日付が Calendar コントロールコントロール階層作成される発生します

データ連結Calendar コントロールではサポートされていませんが、各日セル内容と書式は変更できますCalendar コントロールは、Web ページ表示される前に構成要素であるコンポーネント作成してアセンブルます。DayRender イベントは、Calendar コントロール各日セル作成されるときに発生しますDayRender イベントイベント ハンドラコード記述することで、日付セル作成時にその内容と書式を制御できます日付セル内容カスタマイズする方法詳細については、OnDayRender のトピック参照してください

メモメモ

DayRender イベントCalendar コントロール表示中に発生するため、ユーザーイベント発生させる可能性がある LinkButton などのコントロール追加できません。追加できるのは System.Web.UI.LiteralControl、LabelImageHyperLink などのスタティック コントロールだけです。

イベント処理詳細については、「イベントデリゲート」を参照してください

使用例使用例

DayRender イベントハンドラ指定およびコード化して、表示された月の日付背景色黄色にする方法次のコード例示します。このコード例では、セルSystem.Web.UI.LiteralControl コントロール追加してセル内容カスタマイズする方法示します

<%@ Page Language="VB" AutoEventWireup="True"
 %>
<html>
<head>

   <script language="VB" runat="server">
   
        Sub DayRender(source As Object,
 e As DayRenderEventArgs)
            
            ' Change the background color of the days in the month
            ' to yellow.
            If Not e.Day.IsOtherMonth And
 Not e.Day.IsWeekend Then
                e.Cell.BackColor = System.Drawing.Color.Yellow
            End If 
            ' Add custom text to cell in the Calendar control.
            If e.Day.Date.Day = 18 Then
                e.Cell.Controls.Add(New LiteralControl(ChrW(60)
 & "br" & ChrW(62) & "Holiday"))
            End If 
        End Sub 'DayRender 

   </script>
 
</head>
 
<body>
 
   <form runat="server">

      <h3>DayRender Event Example</h3>
 
      <asp:Calendar id="calendar1" 
                    OnDayRender="DayRender"
                    runat="server">

         <WeekendDayStyle BackColor="gray">
         </WeekendDayStyle>

      </asp:Calendar>
                   
   </form>
          
</body>
</html>
   
<%@ Page Language="C#" AutoEventWireup="True" %>
<html>
<head>

   <script language="C#" runat="server">
   
      void DayRender(Object source, DayRenderEventArgs e) 
      {

         // Change the background color of the days in the month
         // to yellow.
         if (!e.Day.IsOtherMonth && !e.Day.IsWeekend)
            e.Cell.BackColor=System.Drawing.Color.Yellow;

         // Add custom text to cell in the Calendar control.
         if (e.Day.Date.Day == 18)
            e.Cell.Controls.Add(new LiteralControl("<br>Holiday"));

      }

   </script>
 
</head>
 
<body>
 
   <form runat="server">

      <h3>DayRender Event Example</h3>
 
      <asp:Calendar id="calendar1" 
                    OnDayRender="DayRender"
                    runat="server">

         <WeekendDayStyle BackColor="gray">
         </WeekendDayStyle>

      </asp:Calendar>
                   
   </form>
          
</body>
</html>
   
<%@ Page Language="JScript" AutoEventWireup="True" %>
<html>
<head>

   <script language="JScript" runat="server">
   
      function DayRender(source : Object, e : DayRenderEventArgs)
 
      {

         // Change the background color of the days in the month
         // to yellow.
         if (!e.Day.IsOtherMonth && !e.Day.IsWeekend)
            e.Cell.BackColor=System.Drawing.Color.Yellow;

         // Add custom text to cell in the Calendar control.
         if (e.Day.Date.Day == 18)
            e.Cell.Controls.Add(new LiteralControl("<br>Holiday"));

      }

   </script>
 
</head>
 
<body>
 
   <form runat="server">

      <h3>DayRender Event Example</h3>
 
      <asp:Calendar id="calendar1" 
                    OnDayRender="DayRender"
                    runat="server">

         <WeekendDayStyle BackColor="gray">
         </WeekendDayStyle>

      </asp:Calendar>
                   
   </form>
          
</body>
</html>
   
<%@ Page Language="VB" AutoEventWireup="True"
 %>
<html>
<head>

   <script runat="server">
   
      Sub DayRender(sender as Object,
 e As DayRenderEventArgs) 

         ' Change the background color of the days in the month
         ' to yellow.
         If (Not e.Day.IsOtherMonth) And
 (Not e.Day.IsWeekend) Then
        
            e.Cell.BackColor=System.Drawing.Color.Yellow
         
         End If

         ' Add custom text to cell in the Calendar control.
         If e.Day.Date.Day = 18 Then
         
            e.Cell.Controls.Add(New LiteralControl("<br>Holiday"))
         
         End If

      End Sub

      Sub Page_Load(sender As Object,
 e As EventArgs)

         ' Manually register the event-handling method for the DayRender
  
         ' event of the Calendar control.
         AddHandler Calendar1.DayRender, AddressOf
 DayRender

      End Sub

   </script>
 
</head>
 
<body>
 
   <form runat="server">

      <h3>Calendar DayRender Example</h3>
 
      <asp:Calendar id="Calendar1" 
                    runat="server">

         <WeekendDayStyle BackColor="gray">
         </WeekendDayStyle>

      </asp:Calendar>
                   
   </form>
          
</body>
</html>
   
<%@ Page Language="C#" AutoEventWireup="True" %>
<html>
<head>

   <script runat="server">
   
      void DayRender(Object sender, DayRenderEventArgs e) 
      {

         // Change the background color of the days in the month
         // to yellow.
         if (!e.Day.IsOtherMonth && !e.Day.IsWeekend)
         {
            e.Cell.BackColor=System.Drawing.Color.Yellow;
         }

         // Add custom text to cell in the Calendar control.
         if (e.Day.Date.Day == 18)
         {
            e.Cell.Controls.Add(new LiteralControl("<br>Holiday"));
         }

      }

      void Page_Load(Object sender, EventArgs e)
      {

         // Manually register the event-handling method for the DayRender
  
         // event of the Calendar control.
         Calendar1.DayRender += new DayRenderEventHandler(this.DayRender);

      }

   </script>
 
</head>
 
<body>
 
   <form runat="server">

      <h3>Calendar DayRender Example</h3>
 
      <asp:Calendar id="Calendar1" 
                    runat="server">

         <WeekendDayStyle BackColor="gray">
         </WeekendDayStyle>

      </asp:Calendar>
                   
   </form>
          
</body>
</html>
   
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「Calendar.DayRender イベント」の関連用語

Calendar.DayRender イベントのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Calendar.DayRender イベントのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS