C#.NET
[마스터페이지 , masterpage ] PreviousPage 마스터페이지 컨트롤러에 접근
스티커
2009. 5. 20. 14:53
페이지간 게시중 여러가지 중에서
2.0 에서는 Page.PreviousPage 속성이 있따
ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.ko/dv_aspnetcon/html/fedf234e-b7c4-4644-a9e8-c1c0870b043b.htm
간단한 사용법
a.aspx 의 TextBox1 컨트롤의 데이터 값을 b.aspx 에서 엑세스 할수 있다
a.aspx
<asp:TextBox ID="TextBox1" runat="server" Height="100px" TextMode="MultiLine" Width="569px"></asp:TextBox>
<asp:ImageButton ID="ImageButtonFreeView" runat="server" PostBackUrl="Preview.aspx" />
b.aspx
if (Page.PreviousPage != null) { TextBox SourceTextBox = (TextBox)Page.PreviousPage.FindControl("TextBox1"); if (SourceTextBox != null) { Label1.Text = SourceTextBox.Text; } }
마스터 페이지 컨트롤에 접근할떄
ContentPlaceHolder 는 마스터페이지의 컨텐츠 영역입니다. 그 영역안에 있는 컨트롤 접근방법입니다
if (PreviousPage != null && PreviousPage.IsCrossPagePostBack) { if (PreviousPage.Master.FindControl("ContentPlaceHolder1") != null) { Response.Write(((TextBox)PreviousPage.Master.FindControl("ContentPlaceHolder1").FindControl("TextBoxMyEmail")).Text); } } else { Response.Write("Not a cross page postback"); }