DayRenderEventArgs.SelectUrl プロパティ
アセンブリ: System.Web (system.web.dll 内)


表示する日付をユーザーが Calendar コントロール内で選択したときにサーバーにページをポストバックするためのスクリプトを取得するには、SelectUrl プロパティを使用します。このプロパティは、通常、日付に関して表示された内容をカスタマイズしたときにポストバック動作を保存する場合に使用します。

今日の日付について表示する内容をカスタマイズする方法を次のコード例に示します。ユーザーが今日の日付を選択すると Calendar コントロールがサーバーにポストバックするように、SelectUrl プロパティの値が表示内容に挿入されます。
<%@ Page Language="VB" %> <script runat="server"> Sub ScheduleCalendar_DayRender(ByVal sender As Object, ByVal e As DayRenderEventArgs) Handles ScheduleCalendar.DayRender ' Customize the caption for today's date. If e.Day.IsToday Then ' Create the content to render for today's date. Use the ' SelectUrl property to retrieve the script used to post ' the page back to the server when the user selects the ' date. Dim dayContent As String = "<a href=""" & e.SelectUrl & _ """><img border=""0"" alt=""Today"" src=""today.jpg""/></a>" ' Display the custom content in the date cell. e.Cell.Text = dayContent End If End Sub </script> <html> <body> <form runat="server"> <asp:calendar id="ScheduleCalendar" runat="server"/> </form> </body> </html>
<script runat="server"> void ScheduleCalendar_DayRender(object sender, DayRenderEventArgs e) { // Customize the caption for today's date. if(e.Day.IsToday) { // Create the content to render for today's date. Use the // SelectUrl property to retrieve the script used to post // the page back to the server when the user selects the // date. string dayContent = "<a href=\"" + e.SelectUrl + "\"><img border=\"0\" alt=\"Today\" src=\"today.jpg\"/></a>"; // Display the custom content in the date cell. e.Cell.Text = dayContent; } } </script> <html> <body> <form runat="server"> <asp:calendar id="ScheduleCalendar" ondayrender="ScheduleCalendar_DayRender" runat="server"/> </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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- DayRenderEventArgs.SelectUrl プロパティのページへのリンク