Calendar コントロールに表示されるセルを表す TableCell オブジェクトを取得します。
名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文
'宣言
Public ReadOnly Property Cell As TableCell
'使用
Dim instance As DayRenderEventArgs
Dim value As TableCell
value = instance.Cell
public TableCell Cell { get; }
public:
property TableCell^ Cell {
TableCell^ get ();
}
/** @property */
public TableCell get_Cell ()
public function get Cell () : TableCell
適用できません。
プロパティ値
Calendar に表示するセルを表す TableCell。
解説
Cell プロパティを使用して、Calendar コントロールに表示されるセルをプログラムにより制御します。
Cell プロパティの Control.Controls コレクションにコントロールを動的に追加することにより、セルの内容をカスタマイズできます。
![]() |
---|
DayRender イベントは Calendar コントロールの表示中に発生するため、ユーザーはイベントを発生させる可能性がある LinkButton などのコントロールを追加できません。追加できるのは LiteralControl、Label、Image、HyperLink などのスタティック コントロールだけです。 |
使用例
Cell プロパティを使用して、表示された月の日付の背景色をプログラムにより黄色に変更するコード例を次に示します。Cell プロパティの Control.Controls コレクションに System.Web.UI.LiteralControl コントロールを追加して、セルの内容をカスタマイズする方法も示します。
<%@ 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>
<%@ 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>
プラットフォーム
Windows 98,Windows Server 2000 SP4,Windows CE,Windows Millennium Edition,Windows Mobile for Pocket PC,Windows Mobile for Smartphone,Windows Server 2003,Windows XP Media Center Edition,Windows XP Professional x64 Edition,Windows XP SP2,Windows XP Starter Edition
Microsoft .NET Framework 3.0 は Windows Vista,Microsoft Windows XP SP2,および Windows Server 2003 SP1 でサポートされています。
バージョン情報
.NET Framework
サポート対象 : 3.0,2.0,1.1,1.0
参照
関連項目
DayRenderEventArgs クラス
DayRenderEventArgs メンバ
System.Web.UI.WebControls 名前空間
TableCell
CalendarDay
Calendar
Day
SelectUrl
Calendar.DayRender イベント