Calendar.TodaysDate Propiedad

Definición

Obtiene o establece el valor de la fecha actual.

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

Valor de propiedad

DateTime

Un objeto DateTime que contiene el valor que el control Calendar considera que es la fecha actual. Si no se establece esta propiedad explícitamente, esta fecha será la fecha del servidor.

Atributos

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar la TodaysDate propiedad para establecer mediante programación el valor de la fecha actual en el Calendar control.

<%@ 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>

Comentarios

Use la propiedad para determinar la TodaysDate fecha de hoy. También puede usar esta propiedad para establecer mediante programación el valor de la fecha actual en el Calendar control. Esta propiedad se establece mediante un System.DateTime objeto .

Nota

Es posible que sea necesario ajustar esta fecha para dar cabida a los usuarios que se encuentran en una zona horaria diferente.

La apariencia de la fecha especificada por la TodaysDate propiedad se puede personalizar mediante la TodayDayStyle propiedad .

Nota

Si no se establece la VisibleDate propiedad , la fecha especificada por la TodaysDate propiedad determina qué mes se muestra en el Calendar control .

Se aplica a

Consulte también