첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
------------------------------------------------------------------------------------------------------------------------------------------------------
728x90
728x170

TestProject.zip
다운로드

▶ TimeControl.ascx

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TimeControl.ascx.cs" Inherits="TestProject.TimeControl" %>
<%@ OutputCache Duration="5" VaryByParam="None" %>
<asp:Label ID="timeLabel" runat="server" />

 

728x90

 

▶ TimeControl.ascx.cs

using System;
using System.Web.UI;

namespace TestProject
{
    /// <summary>
    /// 시간 컨트롤
    /// </summary>
    public partial class TimeControl : UserControl
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Protected

        #region 페이지 로드시 처리하기 - Page_Load(sender, e)

        /// <summary>
        /// 페이지 로드시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            this.timeLabel.Text = DateTime.Now.ToString();
        }

        #endregion
    }
}

 

300x250

 

▶ MainPage.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MainPage.aspx.cs" Inherits="TestProject.MainPage" %>
<%@ Register TagPrefix="local" Src="~/TimeControl.ascx"
    TagName="TimeControl" %>
<!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>OutputCache 지시자 : 캐시 사용하기</title>
    </head>
    <body>
        <form id="form" runat="server">
            <div>
                현재 시간 (웹 폼) : <asp:Label ID="timeLabel" runat="server" />
                <hr />
                현재 시간 (사용자 정의 컨트롤) : <local:TimeControl ID="timeControl" runat="server" />
            </div>
        </form>
    </body>
</html>

 

▶ MainPage.aspx.cs

using System;
using System.Web.UI;

namespace TestProject
{
    /// <summary>
    /// 메인 페이지
    /// </summary>
    public partial class MainPage : Page
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Protected

        #region 페이지 로드시 처리하기 - Page_Load(sender, e)

        /// <summary>
        /// 페이지 로드시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            this.timeLabel.Text = DateTime.Now.ToString();
        }

        #endregion
    }
}
728x90
그리드형(광고전용)
Posted by icodebroker
,