블로그 이미지
Magic_kit
study 관련자료를 한곳으로 자기 개발 목적으로 재태크 재무 관리 목적으로 일상생활의 팁을 공유 하기 위하여 블로그를 개설 하였습니다.

calendar

1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

Category

Recent Post

Recent Comment

Archive

2009. 10. 28. 11:27 .Net Project/ASP.NET 3.5 Sp1
반응형
MasterPage 활용하여  ScriptManagerProxy 추가 해보자


 마스터 페이지 기본으로 추가 완료 .master

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs"
                    Inherits="MasterPage" %>

<!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 runat="server">
    <title>MasterPage 활용</title>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <div>
         //최상위에 항상 기본적으로 추가 해야 한다
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
       
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                  현재시간 :
                 <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
                <asp:Timer ID="Timer1" runat="server" Interval="1000" ontick="Timer1_Tick">
                </asp:Timer>
            </ContentTemplate>
        </asp:UpdatePanel>        
       
        <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
            <asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
            </asp:ScriptManagerProxy>
        </asp:ContentPlaceHolder>
        <hr />
        <asp:UpdatePanel ID="UpdatePanel2" runat="server">
            <ContentTemplate>
                <asp:Label ID="Label2" runat="server" Text="Label" ForeColor="Red"></asp:Label>
                <asp:Button ID="Button1" runat="server"
                        Text="프록시서버" onclick="Button1_Click" />
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    </form>
</body>
</html>


웹폼 추가시 마스터 페이지 상속받을 것이라고 하여, 체크박스에 마스터페이지 체크 후 생성 

마스터 페이지 상속받을 웹 폼  FrmScriptManagerProxy.aspx 추가

 <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master"
        AutoEventWireup="true" CodeFile="FrmScriptManagerProxy.aspx.cs"
        Inherits="FrmScriptManagerProxy" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
</asp:Content>


FrmMasterPage.Cs 

using System;
using System.Web.UI.WebControls;

public partial class MasterPage : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
          //Empty
    }
    protected void Timer1_Tick(object sender, EventArgs e)
    {
        Label1.Text = DateTime.Now.ToLongTimeString();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Label2.Text = DateTime.Now.ToLongTimeString();
    }




반응형
posted by Magic_kit
2009. 10. 28. 11:16 .Net Project/ASP.NET 3.5 Sp1
반응형


                                               UpdateProgress 컨트롤 사용  
FrmUpdateProgress.aspx

 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="FrmUpdateProgress.aspx.cs"
         Inherits="FrmUpdateProgress" %>

<!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 runat="server">
    <title>Update Progress</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
       
        아래에 오래 걸리는 기능 구현          
       
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
                <asp:Button ID="Button1" runat="server" Text="확인" onclick="Button1_Click" />
                    <br /> 
                    3초 걸리는 작업
            </ContentTemplate>
        </asp:UpdatePanel>
       
        <asp:UpdateProgress ID="UpdateProgress1" runat="server"
                AssociatedUpdatePanelID ="UpdatePanel1">
            <ProgressTemplate>
                <span style="color:Red;">
                로딩중....</span>
            </ProgressTemplate>
        </asp:UpdateProgress>
   
    </div>
    </form>
</body>
</html>



 FrmUpdateProgress.aspx.Cs

using System;
using System.Web.UI.WebControls;

public partial class FrmUpdateProgress : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
          //Empty
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //시간 지연
        System.Threading.Thread.Sleep(3000); //3초 지연

        this.Label1.Text = DateTime.Now.ToLongTimeString();
    }
}


반응형
posted by Magic_kit
2009. 10. 28. 10:43 .Net Project/ASP.NET 3.5 Sp1
반응형



TimerControl 이란 ??
 
FrmTimerControl.aspx

 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="FrmTimer.aspx.cs"
         Inherits="FrmTimer" %>

<!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 runat="server">
    <title>타이머 컨트롤</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
    타이머 컨트롤 <br />
    <hr />
        
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
             현재시간 :
              <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
              <asp:Timer ID="Timer1" runat="server" Interval="1000" ontick="Timer1_Tick">
              </asp:Timer>   
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    </form>
</body>
</html>


FrmTimerControl.aspx.Cs

using System;
using System.Web.UI.WebControls;

public partial class FrmTimer : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
          //Empty
    }
    protected void Timer1_Tick(object sender, EventArgs e)
    {
        //지정된 시간마다 현재 이벤트 핸들러 실행
        this.Label1.Text = DateTime.Now.ToLongTimeString();
     }
}




반응형
posted by Magic_kit
2009. 10. 28. 10:17 .Net Project/ASP.NET 3.5 Sp1
반응형
 
 
1. FrmAjaxWebForm.aspx 윈폼 생성
 2. AJAX 확장 메뉴에서 ScriptManager 컨트롤러 추가
 3. 전체 페이지 포스트백 과 부분 페이지 포스트 백의 차이점 (AJAX컨트롤 사용하는방법)
 4. 자신이 원하는 부분에 적용하고자 할때 UpdatePanel 사용 하도록 한다.




 FrmAjaxWebForm.aspx

 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="FrmAjaxWebForm.aspx.cs" Inherits="FrmAjaxWebForm" %>

<!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 runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
       
        </asp:ScriptManager>
        전체 페이지 포스트 백(다시게시) : ASP.NET Ajax 컨트롤 적용전<br />
        <asp:Label ID="Label1" runat="server" Text="Label" ForeColor="Red"></asp:Label>
        <asp:Button ID="Button1" runat="server" Text="확인" onclick="Button1_Click" /> <br />
       
        부분 페이지 포스트 백(다시게시):ASP.NET AJAX -> Microsoft Ajax 컨트롤 사용
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                  <asp:Label ID="Label2" runat="server" Text="Label" 
                          ForeColor="Red"></asp:Label>
                  <asp:Button ID="Button2" runat="server" Text="적용" onclick="Button2_Click" /> 
            </ContentTemplate>
        </asp:UpdatePanel>         
        
        <asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
    </div>
    </form>
</body>
</html>


 FrmAjaxWebForm.aspx.Cs

using System;
using System.Web.UI.WebControls;

public partial class FrmAjaxWebForm : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
         //Empty
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //현재 시간을 ToLongTimeString()속성 사용하여 Label에 출력
        this.Label1.Text = DateTime.Now.ToLongTimeString();
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        this.Label2.Text = DateTime.Now.ToLongTimeString();
    }
}







반응형
posted by Magic_kit