Share via


DayRenderEventArgs.SelectUrl プロパティ

定義

表示する日付をユーザーが Calendar コントロール内で選択したときに、サーバーにページをポストバックするためのスクリプトを取得します。

public:
 property System::String ^ SelectUrl { System::String ^ get(); };
public string SelectUrl { get; }
member this.SelectUrl : string
Public ReadOnly Property SelectUrl As String

プロパティ値

String

表示する日付をユーザーが選択したときにサーバーにページをポストバックするためのスクリプト。

次のコード例は、今日の日付にレンダリングされるコンテンツをカスタマイズする方法を示しています。 プロパティの SelectUrl 値がレンダリングされたコンテンツに挿入され、ユーザーが Calendar 今日の日付を選択したときにコントロールがサーバーにポストバックされます。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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 xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <asp:calendar id="ScheduleCalendar"
        ondayrender="ScheduleCalendar_DayRender" 
        runat="server"/> 
    
    </form>
  </body>
</html>

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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 xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <asp:calendar id="ScheduleCalendar"
        runat="server"/> 
    
    </form>
  </body>
</html>

注釈

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

適用対象

こちらもご覧ください