ASP.NET
6. 닷넷 기초 (현재시간 출력하기)
왕초보코딩탈출
2018. 2. 25. 16:38
Label 컨트롤을 활용하여 현재 시간을 출력해봅니다.~
레이블이란 : 웹 폼에 편집이 불가능한 문자열을 출력하고자 할때 사용한다고 하네요 ㅎㅎ
test8.aspx
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test8.aspx.cs" Inherits="FrmText.test8" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> </head> <body> <form id="form1" runat="server"> <div> 현재시간: <asp:Label ID="lalDateTime" runat="server" ></asp:Label> </div> </form> </body> </html> | cs |
test8.aspx.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace FrmText { public partial class test8 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { //현재 날짜와 시간을 출력 this.lalDateTime.Text = DateTime.Now.ToString(); } } } | cs |
화면