Está en la página 1de 1

Agregando un label para la visualizacion de la fecha y hora en mi Webform C#

En el defaul.aspx

<table style="width:100%;">
<tr>
<td class="style1">
<asp:Label ID="lbl_fecha_y_hora" runat="server" Text="Fecha y Hora:" Font-Bold="True"
Font-Italic="True" ForeColor="Red"></asp:Label>
</td>
<td>
<asp:Label ID="lbl_fecha_hora" runat="server" Text=""></asp:Label>
</td>
</tr>
</table>

En el defaul.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page


{
protected void Page_Load(object sender, EventArgs e)
{
lbl_fecha_hora.Text = DateTime.Now.ToString();
}
}

También podría gustarte