Calendar.TodaysDate 속성

정의

오늘 날짜의 값을 가져오거나 설정합니다.

public:
 property DateTime TodaysDate { DateTime get(); void set(DateTime value); };
[System.ComponentModel.Bindable(true)]
[System.ComponentModel.Browsable(false)]
public DateTime TodaysDate { get; set; }
[System.ComponentModel.Browsable(false)]
public DateTime TodaysDate { get; set; }
[<System.ComponentModel.Bindable(true)>]
[<System.ComponentModel.Browsable(false)>]
member this.TodaysDate : DateTime with get, set
[<System.ComponentModel.Browsable(false)>]
member this.TodaysDate : DateTime with get, set
Public Property TodaysDate As DateTime

속성 값

DateTime

DateTime에서 오늘 날짜로 간주하는 값이 들어 있는 Calendar입니다. 이 속성이 명시적으로 설정되지 않은 경우 이 날짜는 서버의 날짜가 됩니다.

특성

예제

다음 코드 예제에서는 컨트롤에 TodaysDate 오늘 날짜 Calendar 에 대 한 값을 프로그래밍 방식으로 설정 하는 속성을 사용 하는 방법을 보여 줍니다.

<%@ 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>Calendar Example</title>
<script language="C#" runat="server">

      void Selection_Change(Object sender, EventArgs e) 
      {
         Calendar1.TodaysDate = Calendar1.SelectedDate;
         Label1.Text = "Today's Date is now " + Calendar1.TodaysDate.ToShortDateString();
      }

   </script>

</head>     
<body>

   <form id="form1" runat="server">

      <h3>Calendar Example</h3>

      Select a date on the Calendar control to use as today's date.<br /><br />

      <asp:Calendar ID="Calendar1" runat="server"  
           SelectionMode="Day" 
           ShowGridLines="True" 
           OnSelectionChanged="Selection_Change">

         <SelectedDayStyle BackColor="Yellow"
                           ForeColor="Red">
         </SelectedDayStyle>

      </asp:Calendar> 

      <hr /><br />

      <asp:Label id="Label1" runat="server" />

   </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>Calendar Example</title>
<script language="VB" runat="server">

        Sub Selection_Change(sender As Object, e As EventArgs)
            Calendar1.TodaysDate = Calendar1.SelectedDate
            Label1.Text = "Today's Date is now " & Calendar1.TodaysDate.ToShortDateString()
        End Sub 'Selection_Change

   </script>

</head>     
<body>

   <form id="form1" runat="server">

      <h3>Calendar Example</h3>

      Select a date on the Calendar control to use as today's date.<br /><br />

      <asp:Calendar ID="Calendar1" runat="server"  
           SelectionMode="Day" 
           ShowGridLines="True" 
           OnSelectionChanged="Selection_Change">

         <SelectedDayStyle BackColor="Yellow"
                           ForeColor="Red">
         </SelectedDayStyle>

      </asp:Calendar> 

      <hr /><br />

      <asp:Label id="Label1" runat="server" />

   </form>
</body>
</html>

설명

TodaysDate 오늘 날짜를 확인 하려면 속성을 사용 합니다. 이 속성을 사용하여 컨트롤에서 오늘 날짜 Calendar 의 값을 프로그래밍 방식으로 설정할 수도 있습니다. 이 속성을 사용 하 여 설정 된 System.DateTime 개체입니다.

참고

이 날짜는 다른 표준 시간대에 있는 사용자를 수용하도록 조정해야 할 수도 있습니다.

속성을 사용하여 TodayDayStyle 속성에 지정된 날짜의 TodaysDate 모양을 사용자 지정할 수 있습니다.

참고

속성이 VisibleDate 설정되지 않은 경우 속성에서 지정한 날짜에 TodaysDate 따라 컨트롤에 표시되는 월이 Calendar 결정됩니다.

적용 대상

추가 정보