DayRenderEventArgs.Cell 속성

정의

TableCell 컨트롤에 렌더링되는 셀을 나타내는 Calendar 개체를 가져옵니다.

public:
 property System::Web::UI::WebControls::TableCell ^ Cell { System::Web::UI::WebControls::TableCell ^ get(); };
public System.Web.UI.WebControls.TableCell Cell { get; }
member this.Cell : System.Web.UI.WebControls.TableCell
Public ReadOnly Property Cell As TableCell

속성 값

TableCell에 렌더링되는 셀을 나타내는 Calendar입니다.

예제

다음 코드 예제를 사용 Cell 하는 방법에 설명 합니다 속성을 프로그래밍 방식으로 표시 된 월에 일의 배경색을 노란색으로 변경 합니다. 또한 컨트롤을 속성 컬렉션에 추가하여 System.Web.UI.LiteralControl 셀 내용을 사용자 지정하는 Control.ControlsCell 방법도 보여 줍니다.

<%@ Page Language="C#" AutoEventWireup="True" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>DayRender Event Example</title>
<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 />Birthday"));

      }

   </script>
 
</head>
 
<body>
 
   <form id="form1" 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" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>DayRender Event Example</title>
<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("<br />" & "Birthday"))
        End If 
    End Sub 'DayRender
  </script>
 
</head>
 
<body>
 
   <form id="form1" runat="server">

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

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

      </asp:Calendar>
                   
   </form>
          
</body>
</html>

설명

사용 된 Cell 속성을 프로그래밍 방식으로 컨트롤에서 렌더링 되는 셀을 제어 합니다 Calendar .

컨트롤을 속성 컬렉션에 동적으로 추가하여 셀의 Cell 내용을 사용자 지정할 수 있습니다Control.Controls.

참고

컨트롤이 DayRender 렌더링되는 동안 Calendar 이벤트가 발생하므로 와 같은 LinkButton이벤트를 발생시키는 컨트롤을 추가할 수 없습니다. , , LabelImageHyperLink와 같은 LiteralControl정적 컨트롤만 추가할 수 있습니다.

적용 대상

추가 정보