|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Master Pages and Cross-Page Form InformationFor example, on page 1 (default.aspx): -- <%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Title="Untitled Page" %> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> Stuff with post back: <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:Button ID="Button1" runat="server" PostBackUrl="~/Step2.aspx" Text="Button" /> </asp:Content> -- Simple enough... on the PostBack page, I want to just read what was typed in that textbox. -- <%@ Page Language="C#" EnableViewStateMac="false" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Step2.aspx.cs" Inherits="Step2" Title="Untitled Page" %> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> In step 1, you typed: <% Response.Write(Request.Form["TextBox1"]; %> </asp:Content> -- The master page consists of the default code: -- <%@ 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>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:contentplaceholder id="ContentPlaceHolder1" runat="server"> </asp:contentplaceholder> </div> </form> </body> </html> -- Is there something about the master page that I'm missing? Any good references/resources to using master pages would also be appreciated. :) I have no trouble fishing for it, however, today, not only were the fish gone, but the pond was dry. Thanks in advance! -David -------------------------------------------------------------------------- David R. Longnecker CCNA, MCSA, Network+, A+ Management Information Services Wichita Public Schools, USD 259 Hi David,
Welcome to MSDN newsgroup. As for the querying TextBox values from Previous page when doing cross page postback in asp.net 2.0, here are some of my understanding and suggestion: 1. the form values did exist in the Page.Request.Form collection. However, since we're using Master page, the textboxes are cotained in the ContentPlaceHolder which itself a child conttrol in the page's control structure, so to avoid naming clash, the asp.net page will generate a unique ID for all the child controsl in it (mangling their ID).... So we can not use those Textboxs' original ID to query value from request.Form collection. But we can printout them through the following code (to confirm that they did exists..): ===================== protected void Page_Load(object sender, EventArgs e) { if (PreviousPage != null && PreviousPage.IsCrossPagePostBack) { foreach (string key in Request.Form.Keys) { Response.Write("<br>" + key + ": " +Request.Form[key]); } } } ==================== 2. Actually the recommended means to retrieve Control property values in Previous for cross page postback is defining some public Properties in the Previous page's page class code which expose those certain controls' property.... Then, we can use those Properties in the Target page's code.... e.g: Suppose we have two pages: The first page is as below: ==========step1.aspx=========== <%@ Page Language="C#" MasterPageFile="~/CrossPost/TM.master" AutoEventWireup="true" CodeFile="Step1.aspx.cs" Inherits="CrossPost_Step1" Title="Untitled Page" %> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <br /> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br /> <asp:Button ID="btnCrossPost" runat="server" PostBackUrl="~/CrossPost/Step2.aspx" Text="Cross Post Back" /> </asp:Content> And the codebehind is ==========step1.aspx.cs============ public partial class CrossPost_Step1 : System.Web.UI.Page { public string TextBox1Value { get { return TextBox1.Text; } } public string TextBox2Value { get { return TextBox2.Text; } } } the target page (step2.aspx)'s aspx and codebehind: =======step2.aspx============ <%@ Page Language="C#" MasterPageFile="~/CrossPost/TM.master" AutoEventWireup="true" CodeFile="Step2.aspx.cs" Inherits="CrossPost_Step2" Title="Untitled Page" %> <%@ Reference Page="~/CrossPost/Step1.aspx" %> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> </asp:Content> =====step2.aspx.cs========== protected void Page_Load(object sender, EventArgs e) { if (PreviousPage != null && PreviousPage.IsCrossPagePostBack) { CrossPost_Step1 page1 = PreviousPage as CrossPost_Step1; if (page1 != null) { Response.Write("<br>" + page1.TextBox1Value); Response.Write("<br>" + page1.TextBox2Value); } } } ============================ Note that the below directive in the step2.aspx is very important: <%@ Reference Page="~/CrossPost/Step1.aspx" %> this indicate that we'll reference that page (~/CrossPost/Step1.aspx)'s class or code in this page so that the asp.net runtime will compile them into same assembly so as to make them visible to each other............... Some additional resource: http://www.asp.net/QuickStart/aspnet/doc/tipstricks/default.aspx#crosspage http://msdn2.microsoft.com/en-us/library/ms178139.aspx Regards, Steven Cheng Microsoft Online Support Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.) -------------------- Show quoteHide quote | From: "David R. Longnecker" <dlongnecker@community.nospam> microsoft.public.dotnet.framework.aspnet.webcontrols:32036| Subject: Master Pages and Cross-Page Form Information | Date: Tue, 27 Dec 2005 01:08:22 -0600 | Lines: 223 | MIME-Version: 1.0 | Content-Type: multipart/alternative; | boundary="----=_NextPart_000_0034_01C60A82.08696930" | X-Priority: 3 | X-MSMail-Priority: Normal | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 | Message-ID: <u9vaURrCGHA.***@TK2MSFTNGP14.phx.gbl> | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols | NNTP-Posting-Host: ip24-255-143-36.ks.ks.cox.net 24.255.143.36 | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl | Xref: TK2MSFTNGXA02.phx.gbl | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols so far, really enjoying it. A couple of questions to help kickstart my | | I'm slowly learning the new caveats of master pages and ASP.NET 2.0 and, mind from the old ASP3 days. From what I've found, 2.0's cross-page posting allows me to set a PostBackURL and then Request.Form["objectName"] the information into the next page. Okay, that works up until I use Master Pages for my central header/footers. Using the Master Pages, it appears nothing is past to the Postback page; however, an error is not generated. | For example, on page 1 (default.aspx): AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" | -- | <%@ Page Language="C#" MasterPageFile="~/MasterPage.master" Title="Untitled Page" %> | <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">| Stuff with post back: Text="Button" />| <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> | <asp:Button ID="Button1" runat="server" PostBackUrl="~/Step2.aspx" | </asp:Content> in that textbox.| -- | Simple enough... on the PostBack page, I want to just read what was typed | -- MasterPageFile="~/MasterPage.master" AutoEventWireup="true" | <%@ Page Language="C#" EnableViewStateMac="false" CodeFile="Step2.aspx.cs" Inherits="Step2" Title="Untitled Page" %> | <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">| In step 1, you typed: <% Response.Write(Request.Form["TextBox1"]; %> CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>| </asp:Content> | -- | The master page consists of the default code: | -- | <%@ Master Language="C#" AutoEventWireup="true" | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">Show quoteHide quote | <html xmlns="http://www.w3.org/1999/xhtml" > appreciated. :) I have no trouble fishing for it, however, today, not only | <head runat="server"> | <title>Untitled Page</title> | </head> | <body> | <form id="form1" runat="server"> | <div> | <asp:contentplaceholder id="ContentPlaceHolder1" runat="server"> | </asp:contentplaceholder> | </div> | </form> | </body> | </html> | -- | Is there something about the master page that I'm missing? | Any good references/resources to using master pages would also be were the fish gone, but the pond was dry. Show quoteHide quote | Thanks in advance! | -David | | -------------------------------------------------------------------------- | David R. Longnecker | CCNA, MCSA, Network+, A+ | Management Information Services | Wichita Public Schools, USD 259 | | Hi David,
Have you got the issue resolved or does my last reply helps you a little? If there're anything else we can help, please feel free to post here. Regards, Steven Cheng Microsoft Online Support Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.) -------------------- Show quoteHide quote | X-Tomcat-ID: 121575119 microsoft.public.dotnet.framework.aspnet.webcontrols:32037| References: <u9vaURrCGHA.***@TK2MSFTNGP14.phx.gbl> | MIME-Version: 1.0 | Content-Type: text/plain | Content-Transfer-Encoding: 7bit | From: stch***@online.microsoft.com (Steven Cheng[MSFT]) | Organization: Microsoft | Date: Tue, 27 Dec 2005 09:18:43 GMT | Subject: RE: Master Pages and Cross-Page Form Information | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols | Message-ID: <voh8NasCGHA.***@TK2MSFTNGXA02.phx.gbl> | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols | Lines: 193 | Path: TK2MSFTNGXA02.phx.gbl | Xref: TK2MSFTNGXA02.phx.gbl Show quoteHide quote | NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122 +Request.Form[key]);| | Hi David, | | Welcome to MSDN newsgroup. | As for the querying TextBox values from Previous page when doing cross page | postback in asp.net 2.0, here are some of my understanding and suggestion: | | 1. the form values did exist in the Page.Request.Form collection. However, | since we're using Master page, the textboxes are cotained in the | ContentPlaceHolder which itself a child conttrol in the page's control | structure, so to avoid naming clash, the asp.net page will generate a | unique ID for all the child controsl in it (mangling their ID).... So we | can not use those Textboxs' original ID to query value from request.Form | collection. But we can printout them through the following code (to confirm | that they did exists..): | ===================== | protected void Page_Load(object sender, EventArgs e) | { | if (PreviousPage != null && PreviousPage.IsCrossPagePostBack) | { | | foreach (string key in Request.Form.Keys) | { | Response.Write("<br>" + key + ": " Show quoteHide quote | } Request.Form["objectName"] | | } | } | ==================== | | | 2. Actually the recommended means to retrieve Control property values in | Previous for cross page postback is defining some public Properties in the | Previous page's page class code which expose those certain controls' | property.... Then, we can use those Properties in the Target page's | code.... e.g: | | Suppose we have two pages: | | | The first page is as below: | ==========step1.aspx=========== | <%@ Page Language="C#" MasterPageFile="~/CrossPost/TM.master" | AutoEventWireup="true" CodeFile="Step1.aspx.cs" Inherits="CrossPost_Step1" | Title="Untitled Page" %> | <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" | Runat="Server"> | <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> | <br /> | <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br /> | <asp:Button ID="btnCrossPost" runat="server" | PostBackUrl="~/CrossPost/Step2.aspx" | Text="Cross Post Back" /> | </asp:Content> | | And the codebehind is | ==========step1.aspx.cs============ | public partial class CrossPost_Step1 : System.Web.UI.Page | { | public string TextBox1Value | { | get | { | return TextBox1.Text; | } | } | | public string TextBox2Value | { | get | { | return TextBox2.Text; | } | } | | | } | | | | the target page (step2.aspx)'s aspx and codebehind: | | =======step2.aspx============ | <%@ Page Language="C#" MasterPageFile="~/CrossPost/TM.master" | AutoEventWireup="true" CodeFile="Step2.aspx.cs" Inherits="CrossPost_Step2" | Title="Untitled Page" %> | <%@ Reference Page="~/CrossPost/Step1.aspx" %> | <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" | Runat="Server"> | </asp:Content> | | | | =====step2.aspx.cs========== | | protected void Page_Load(object sender, EventArgs e) | { | if (PreviousPage != null && PreviousPage.IsCrossPagePostBack) | { | | CrossPost_Step1 page1 = PreviousPage as CrossPost_Step1; | | if (page1 != null) | { | Response.Write("<br>" + page1.TextBox1Value); | Response.Write("<br>" + page1.TextBox2Value); | } | | } | } | | ============================ | | | Note that the below directive in the step2.aspx is very important: | | <%@ Reference Page="~/CrossPost/Step1.aspx" %> | | | this indicate that we'll reference that page (~/CrossPost/Step1.aspx)'s | class or code in this page so that the asp.net runtime will compile them | into same assembly so as to make them visible to each other............... | | Some additional resource: | | http://www.asp.net/QuickStart/aspnet/doc/tipstricks/default.aspx#crosspage | | http://msdn2.microsoft.com/en-us/library/ms178139.aspx | | Regards, | | Steven Cheng | Microsoft Online Support | | Get Secure! www.microsoft.com/security | (This posting is provided "AS IS", with no warranties, and confers no | rights.) | | | | | | -------------------- | | From: "David R. Longnecker" <dlongnecker@community.nospam> | | Subject: Master Pages and Cross-Page Form Information | | Date: Tue, 27 Dec 2005 01:08:22 -0600 | | Lines: 223 | | MIME-Version: 1.0 | | Content-Type: multipart/alternative; | | boundary="----=_NextPart_000_0034_01C60A82.08696930" | | X-Priority: 3 | | X-MSMail-Priority: Normal | | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 | | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 | | Message-ID: <u9vaURrCGHA.***@TK2MSFTNGP14.phx.gbl> | | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols | | NNTP-Posting-Host: ip24-255-143-36.ks.ks.cox.net 24.255.143.36 | | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl | | Xref: TK2MSFTNGXA02.phx.gbl | microsoft.public.dotnet.framework.aspnet.webcontrols:32036 | | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols | | | | I'm slowly learning the new caveats of master pages and ASP.NET 2.0 and, | so far, really enjoying it. A couple of questions to help kickstart my | mind from the old ASP3 days. From what I've found, 2.0's cross-page | posting allows me to set a PostBackURL and then Show quoteHide quote | the information into the next page. Okay, that works up until I use Master | Pages for my central header/footers. Using the Master Pages, it appears | nothing is past to the Postback page; however, an error is not generated. | | For example, on page 1 (default.aspx): | | -- | | <%@ Page Language="C#" MasterPageFile="~/MasterPage.master" | AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" | Title="Untitled Page" %> | | <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" | Runat="Server"> | | Stuff with post back: | | <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> | | <asp:Button ID="Button1" runat="server" PostBackUrl="~/Step2.aspx" | Text="Button" /> | | </asp:Content> | | -- | | Simple enough... on the PostBack page, I want to just read what was typed | in that textbox. | | -- | | <%@ Page Language="C#" EnableViewStateMac="false" | MasterPageFile="~/MasterPage.master" AutoEventWireup="true" | CodeFile="Step2.aspx.cs" Inherits="Step2" Title="Untitled Page" %> | | <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" | Runat="Server"> | | In step 1, you typed: <% Response.Write(Request.Form["TextBox1"]; %> | | </asp:Content> | | -- | | The master page consists of the default code: | | -- | | <%@ 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>Untitled Page</title> | | </head> | | <body> | | <form id="form1" runat="server"> | | <div> | | <asp:contentplaceholder id="ContentPlaceHolder1" runat="server"> | | </asp:contentplaceholder> | | </div> | | </form> | | </body> | | </html> | | -- | | Is there something about the master page that I'm missing? | | Any good references/resources to using master pages would also be | appreciated. :) I have no trouble fishing for it, however, today, not only | were the fish gone, but the pond was dry. | | Thanks in advance! | | -David | | | | -------------------------------------------------------------------------- | | David R. Longnecker | | CCNA, MCSA, Network+, A+ | | Management Information Services | | Wichita Public Schools, USD 259 | | | | | | Steven-
From what I can tell it worked like a charm... battling a IDE issue right now (VS 2005 locking up with "Visual Studio is Busy" that I'm working to resolve right now); however, it seemed to work exactly like I needed. Thanks for your help! -David -- Show quoteHide quoteDavid R. Longnecker CCNA, MCSA, Network+, A+ Management Information Services Wichita Public Schools, USD 259 "Steven Cheng[MSFT]" <stch***@online.microsoft.com> wrote in message news:41i6gIGDGHA.1240@TK2MSFTNGXA02.phx.gbl... > Hi David, > > Have you got the issue resolved or does my last reply helps you a little? > If there're anything else we can help, please feel free to post here. > > Regards, > > Steven Cheng > Microsoft Online Support > > Get Secure! www.microsoft.com/security > (This posting is provided "AS IS", with no warranties, and confers no > rights.) > -------------------- > | X-Tomcat-ID: 121575119 > | References: <u9vaURrCGHA.***@TK2MSFTNGP14.phx.gbl> > | MIME-Version: 1.0 > | Content-Type: text/plain > | Content-Transfer-Encoding: 7bit > | From: stch***@online.microsoft.com (Steven Cheng[MSFT]) > | Organization: Microsoft > | Date: Tue, 27 Dec 2005 09:18:43 GMT > | Subject: RE: Master Pages and Cross-Page Form Information > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols > | Message-ID: <voh8NasCGHA.***@TK2MSFTNGXA02.phx.gbl> > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols > | Lines: 193 > | Path: TK2MSFTNGXA02.phx.gbl > | Xref: TK2MSFTNGXA02.phx.gbl > microsoft.public.dotnet.framework.aspnet.webcontrols:32037 > | NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122 > | > | Hi David, > | > | Welcome to MSDN newsgroup. > | As for the querying TextBox values from Previous page when doing cross > page > | postback in asp.net 2.0, here are some of my understanding and > suggestion: > | > | 1. the form values did exist in the Page.Request.Form collection. > However, > | since we're using Master page, the textboxes are cotained in the > | ContentPlaceHolder which itself a child conttrol in the page's control > | structure, so to avoid naming clash, the asp.net page will generate a > | unique ID for all the child controsl in it (mangling their ID).... So > we > | can not use those Textboxs' original ID to query value from request.Form > | collection. But we can printout them through the following code (to > confirm > | that they did exists..): > | ===================== > | protected void Page_Load(object sender, EventArgs e) > | { > | if (PreviousPage != null && PreviousPage.IsCrossPagePostBack) > | { > | > | foreach (string key in Request.Form.Keys) > | { > | Response.Write("<br>" + key + ": " > +Request.Form[key]); > | } > | > | } > | } > | ==================== > | > | > | 2. Actually the recommended means to retrieve Control property values in > | Previous for cross page postback is defining some public Properties in > the > | Previous page's page class code which expose those certain controls' > | property.... Then, we can use those Properties in the Target page's > | code.... e.g: > | > | Suppose we have two pages: > | > | > | The first page is as below: > | ==========step1.aspx=========== > | <%@ Page Language="C#" MasterPageFile="~/CrossPost/TM.master" > | AutoEventWireup="true" CodeFile="Step1.aspx.cs" > Inherits="CrossPost_Step1" > | Title="Untitled Page" %> > | <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" > | Runat="Server"> > | <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> > | <br /> > | <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br /> > | <asp:Button ID="btnCrossPost" runat="server" > | PostBackUrl="~/CrossPost/Step2.aspx" > | Text="Cross Post Back" /> > | </asp:Content> > | > | And the codebehind is > | ==========step1.aspx.cs============ > | public partial class CrossPost_Step1 : System.Web.UI.Page > | { > | public string TextBox1Value > | { > | get > | { > | return TextBox1.Text; > | } > | } > | > | public string TextBox2Value > | { > | get > | { > | return TextBox2.Text; > | } > | } > | > | > | } > | > | > | > | the target page (step2.aspx)'s aspx and codebehind: > | > | =======step2.aspx============ > | <%@ Page Language="C#" MasterPageFile="~/CrossPost/TM.master" > | AutoEventWireup="true" CodeFile="Step2.aspx.cs" > Inherits="CrossPost_Step2" > | Title="Untitled Page" %> > | <%@ Reference Page="~/CrossPost/Step1.aspx" %> > | <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" > | Runat="Server"> > | </asp:Content> > | > | > | > | =====step2.aspx.cs========== > | > | protected void Page_Load(object sender, EventArgs e) > | { > | if (PreviousPage != null && PreviousPage.IsCrossPagePostBack) > | { > | > | CrossPost_Step1 page1 = PreviousPage as CrossPost_Step1; > | > | if (page1 != null) > | { > | Response.Write("<br>" + page1.TextBox1Value); > | Response.Write("<br>" + page1.TextBox2Value); > | } > | > | } > | } > | > | ============================ > | > | > | Note that the below directive in the step2.aspx is very important: > | > | <%@ Reference Page="~/CrossPost/Step1.aspx" %> > | > | > | this indicate that we'll reference that page (~/CrossPost/Step1.aspx)'s > | class or code in this page so that the asp.net runtime will compile them > | into same assembly so as to make them visible to each > other............... > | > | Some additional resource: > | > | > http://www.asp.net/QuickStart/aspnet/doc/tipstricks/default.aspx#crosspage > | > | http://msdn2.microsoft.com/en-us/library/ms178139.aspx > | > | Regards, > | > | Steven Cheng > | Microsoft Online Support > | > | Get Secure! www.microsoft.com/security > | (This posting is provided "AS IS", with no warranties, and confers no > | rights.) > | > | > | > | > | > | -------------------- > | | From: "David R. Longnecker" <dlongnecker@community.nospam> > | | Subject: Master Pages and Cross-Page Form Information > | | Date: Tue, 27 Dec 2005 01:08:22 -0600 > | | Lines: 223 > | | MIME-Version: 1.0 > | | Content-Type: multipart/alternative; > | | boundary="----=_NextPart_000_0034_01C60A82.08696930" > | | X-Priority: 3 > | | X-MSMail-Priority: Normal > | | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 > | | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 > | | Message-ID: <u9vaURrCGHA.***@TK2MSFTNGP14.phx.gbl> > | | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols > | | NNTP-Posting-Host: ip24-255-143-36.ks.ks.cox.net 24.255.143.36 > | | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl > | | Xref: TK2MSFTNGXA02.phx.gbl > | microsoft.public.dotnet.framework.aspnet.webcontrols:32036 > | | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols > | | > | | I'm slowly learning the new caveats of master pages and ASP.NET 2.0 > and, > | so far, really enjoying it. A couple of questions to help kickstart my > | mind from the old ASP3 days. From what I've found, 2.0's cross-page > | posting allows me to set a PostBackURL and then > Request.Form["objectName"] > | the information into the next page. Okay, that works up until I use > Master > | Pages for my central header/footers. Using the Master Pages, it appears > | nothing is past to the Postback page; however, an error is not > generated. > | | For example, on page 1 (default.aspx): > | | -- > | | <%@ Page Language="C#" MasterPageFile="~/MasterPage.master" > | AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" > | Title="Untitled Page" %> > | | <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" > | Runat="Server"> > | | Stuff with post back: > | | <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> > | | <asp:Button ID="Button1" runat="server" PostBackUrl="~/Step2.aspx" > | Text="Button" /> > | | </asp:Content> > | | -- > | | Simple enough... on the PostBack page, I want to just read what was > typed > | in that textbox. > | | -- > | | <%@ Page Language="C#" EnableViewStateMac="false" > | MasterPageFile="~/MasterPage.master" AutoEventWireup="true" > | CodeFile="Step2.aspx.cs" Inherits="Step2" Title="Untitled Page" %> > | | <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" > | Runat="Server"> > | | In step 1, you typed: <% Response.Write(Request.Form["TextBox1"]; %> > | | </asp:Content> > | | -- > | | The master page consists of the default code: > | | -- > | | <%@ 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>Untitled Page</title> > | | </head> > | | <body> > | | <form id="form1" runat="server"> > | | <div> > | | <asp:contentplaceholder id="ContentPlaceHolder1" runat="server"> > | | </asp:contentplaceholder> > | | </div> > | | </form> > | | </body> > | | </html> > | | -- > | | Is there something about the master page that I'm missing? > | | Any good references/resources to using master pages would also be > | appreciated. :) I have no trouble fishing for it, however, today, not > only > | were the fish gone, but the pond was dry. > | | Thanks in advance! > | | -David > | | > | | > -------------------------------------------------------------------------- > | | David R. Longnecker > | | CCNA, MCSA, Network+, A+ > | | Management Information Services > | | Wichita Public Schools, USD 259 > | | > | | > | > | > Steven-
Okay, I do have a theory question. What happens if/when I need to move through the web site non-linear? The Reference Page means that it has to go sequentially; however, I can foresee times where I'd want to allow the user to go back and forth along the steps. Can you still make the variables public and call them or would I need to place the information into a session each page hop, then do a verification on the final "step"? Thanks! -David -- Show quoteHide quoteDavid R. Longnecker CCNA, MCSA, Network+, A+ Management Information Services Wichita Public Schools, USD 259 "David R. Longnecker" <dlongnecker@community.nospam> wrote in message news:Og%23%23w5yDGHA.3528@TK2MSFTNGP12.phx.gbl... > Steven- > > From what I can tell it worked like a charm... battling a IDE issue right > now (VS 2005 locking up with "Visual Studio is Busy" that I'm working to > resolve right now); however, it seemed to work exactly like I needed. > Thanks for your help! > > -David > > > -- > David R. Longnecker > CCNA, MCSA, Network+, A+ > Management Information Services > Wichita Public Schools, USD 259 > > > "Steven Cheng[MSFT]" <stch***@online.microsoft.com> wrote in message > news:41i6gIGDGHA.1240@TK2MSFTNGXA02.phx.gbl... >> Hi David, >> >> Have you got the issue resolved or does my last reply helps you a little? >> If there're anything else we can help, please feel free to post here. >> >> Regards, >> >> Steven Cheng >> Microsoft Online Support >> >> Get Secure! www.microsoft.com/security >> (This posting is provided "AS IS", with no warranties, and confers no >> rights.) >> -------------------- >> | X-Tomcat-ID: 121575119 >> | References: <u9vaURrCGHA.***@TK2MSFTNGP14.phx.gbl> >> | MIME-Version: 1.0 >> | Content-Type: text/plain >> | Content-Transfer-Encoding: 7bit >> | From: stch***@online.microsoft.com (Steven Cheng[MSFT]) >> | Organization: Microsoft >> | Date: Tue, 27 Dec 2005 09:18:43 GMT >> | Subject: RE: Master Pages and Cross-Page Form Information >> | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols >> | Message-ID: <voh8NasCGHA.***@TK2MSFTNGXA02.phx.gbl> >> | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols >> | Lines: 193 >> | Path: TK2MSFTNGXA02.phx.gbl >> | Xref: TK2MSFTNGXA02.phx.gbl >> microsoft.public.dotnet.framework.aspnet.webcontrols:32037 >> | NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122 >> | >> | Hi David, >> | >> | Welcome to MSDN newsgroup. >> | As for the querying TextBox values from Previous page when doing cross >> page >> | postback in asp.net 2.0, here are some of my understanding and >> suggestion: >> | >> | 1. the form values did exist in the Page.Request.Form collection. >> However, >> | since we're using Master page, the textboxes are cotained in the >> | ContentPlaceHolder which itself a child conttrol in the page's control >> | structure, so to avoid naming clash, the asp.net page will generate a >> | unique ID for all the child controsl in it (mangling their ID).... So >> we >> | can not use those Textboxs' original ID to query value from >> request.Form >> | collection. But we can printout them through the following code (to >> confirm >> | that they did exists..): >> | ===================== >> | protected void Page_Load(object sender, EventArgs e) >> | { >> | if (PreviousPage != null && PreviousPage.IsCrossPagePostBack) >> | { >> | >> | foreach (string key in Request.Form.Keys) >> | { >> | Response.Write("<br>" + key + ": " >> +Request.Form[key]); >> | } >> | >> | } >> | } >> | ==================== >> | >> | >> | 2. Actually the recommended means to retrieve Control property values >> in >> | Previous for cross page postback is defining some public Properties in >> the >> | Previous page's page class code which expose those certain controls' >> | property.... Then, we can use those Properties in the Target page's >> | code.... e.g: >> | >> | Suppose we have two pages: >> | >> | >> | The first page is as below: >> | ==========step1.aspx=========== >> | <%@ Page Language="C#" MasterPageFile="~/CrossPost/TM.master" >> | AutoEventWireup="true" CodeFile="Step1.aspx.cs" >> Inherits="CrossPost_Step1" >> | Title="Untitled Page" %> >> | <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" >> | Runat="Server"> >> | <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> >> | <br /> >> | <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br /> >> | <asp:Button ID="btnCrossPost" runat="server" >> | PostBackUrl="~/CrossPost/Step2.aspx" >> | Text="Cross Post Back" /> >> | </asp:Content> >> | >> | And the codebehind is >> | ==========step1.aspx.cs============ >> | public partial class CrossPost_Step1 : System.Web.UI.Page >> | { >> | public string TextBox1Value >> | { >> | get >> | { >> | return TextBox1.Text; >> | } >> | } >> | >> | public string TextBox2Value >> | { >> | get >> | { >> | return TextBox2.Text; >> | } >> | } >> | >> | >> | } >> | >> | >> | >> | the target page (step2.aspx)'s aspx and codebehind: >> | >> | =======step2.aspx============ >> | <%@ Page Language="C#" MasterPageFile="~/CrossPost/TM.master" >> | AutoEventWireup="true" CodeFile="Step2.aspx.cs" >> Inherits="CrossPost_Step2" >> | Title="Untitled Page" %> >> | <%@ Reference Page="~/CrossPost/Step1.aspx" %> >> | <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" >> | Runat="Server"> >> | </asp:Content> >> | >> | >> | >> | =====step2.aspx.cs========== >> | >> | protected void Page_Load(object sender, EventArgs e) >> | { >> | if (PreviousPage != null && PreviousPage.IsCrossPagePostBack) >> | { >> | >> | CrossPost_Step1 page1 = PreviousPage as >> CrossPost_Step1; >> | >> | if (page1 != null) >> | { >> | Response.Write("<br>" + page1.TextBox1Value); >> | Response.Write("<br>" + page1.TextBox2Value); >> | } >> | >> | } >> | } >> | >> | ============================ >> | >> | >> | Note that the below directive in the step2.aspx is very important: >> | >> | <%@ Reference Page="~/CrossPost/Step1.aspx" %> >> | >> | >> | this indicate that we'll reference that page (~/CrossPost/Step1.aspx)'s >> | class or code in this page so that the asp.net runtime will compile >> them >> | into same assembly so as to make them visible to each >> other............... >> | >> | Some additional resource: >> | >> | >> http://www.asp.net/QuickStart/aspnet/doc/tipstricks/default.aspx#crosspage >> | >> | http://msdn2.microsoft.com/en-us/library/ms178139.aspx >> | >> | Regards, >> | >> | Steven Cheng >> | Microsoft Online Support >> | >> | Get Secure! www.microsoft.com/security >> | (This posting is provided "AS IS", with no warranties, and confers no >> | rights.) >> | >> | >> | >> | >> | >> | -------------------- >> | | From: "David R. Longnecker" <dlongnecker@community.nospam> >> | | Subject: Master Pages and Cross-Page Form Information >> | | Date: Tue, 27 Dec 2005 01:08:22 -0600 >> | | Lines: 223 >> | | MIME-Version: 1.0 >> | | Content-Type: multipart/alternative; >> | | boundary="----=_NextPart_000_0034_01C60A82.08696930" >> | | X-Priority: 3 >> | | X-MSMail-Priority: Normal >> | | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 >> | | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 >> | | Message-ID: <u9vaURrCGHA.***@TK2MSFTNGP14.phx.gbl> >> | | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols >> | | NNTP-Posting-Host: ip24-255-143-36.ks.ks.cox.net 24.255.143.36 >> | | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl >> | | Xref: TK2MSFTNGXA02.phx.gbl >> | microsoft.public.dotnet.framework.aspnet.webcontrols:32036 >> | | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols >> | | >> | | I'm slowly learning the new caveats of master pages and ASP.NET 2.0 >> and, >> | so far, really enjoying it. A couple of questions to help kickstart my >> | mind from the old ASP3 days. From what I've found, 2.0's cross-page >> | posting allows me to set a PostBackURL and then >> Request.Form["objectName"] >> | the information into the next page. Okay, that works up until I use >> Master >> | Pages for my central header/footers. Using the Master Pages, it >> appears >> | nothing is past to the Postback page; however, an error is not >> generated. >> | | For example, on page 1 (default.aspx): >> | | -- >> | | <%@ Page Language="C#" MasterPageFile="~/MasterPage.master" >> | AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" >> | Title="Untitled Page" %> >> | | <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" >> | Runat="Server"> >> | | Stuff with post back: >> | | <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> >> | | <asp:Button ID="Button1" runat="server" >> PostBackUrl="~/Step2.aspx" >> | Text="Button" /> >> | | </asp:Content> >> | | -- >> | | Simple enough... on the PostBack page, I want to just read what was >> typed >> | in that textbox. >> | | -- >> | | <%@ Page Language="C#" EnableViewStateMac="false" >> | MasterPageFile="~/MasterPage.master" AutoEventWireup="true" >> | CodeFile="Step2.aspx.cs" Inherits="Step2" Title="Untitled Page" %> >> | | <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" >> | Runat="Server"> >> | | In step 1, you typed: <% Response.Write(Request.Form["TextBox1"]; %> >> | | </asp:Content> >> | | -- >> | | The master page consists of the default code: >> | | -- >> | | <%@ 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>Untitled Page</title> >> | | </head> >> | | <body> >> | | <form id="form1" runat="server"> >> | | <div> >> | | <asp:contentplaceholder id="ContentPlaceHolder1" runat="server"> >> | | </asp:contentplaceholder> >> | | </div> >> | | </form> >> | | </body> >> | | </html> >> | | -- >> | | Is there something about the master page that I'm missing? >> | | Any good references/resources to using master pages would also be >> | appreciated. :) I have no trouble fishing for it, however, today, not >> only >> | were the fish gone, but the pond was dry. >> | | Thanks in advance! >> | | -David >> | | >> | | >> -------------------------------------------------------------------------- >> | | David R. Longnecker >> | | CCNA, MCSA, Network+, A+ >> | | Management Information Services >> | | Wichita Public Schools, USD 259 >> | | >> | | >> | >> | >> > > Thanks for your response David,
If you want to record such a navigation path so that the user can move forward or backward through that path... I think using SessionState will be prefered. CrossPage posting only make sense when the original using http post to submit to the second page, there're also many other navigation scenarios like Response.Redirect, clientscript redirect.... So I think use SessionState should be the better approach to record such info(when a certain new page is navigated....).. Hope helps. Thanks, Steven Cheng Microsoft Online Support Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.) -------------------- | From: "David R. Longnecker" <dlongnecker@community.nospam> <voh8NasCGHA.***@TK2MSFTNGXA02.phx.gbl> | References: <u9vaURrCGHA.***@TK2MSFTNGP14.phx.gbl> <41i6gIGDGHA.1***@TK2MSFTNGXA02.phx.gbl> <Og##w5yDGHA.3***@TK2MSFTNGP12.phx.gbl> | Subject: Re: Master Pages and Cross-Page Form Information microsoft.public.dotnet.framework.aspnet.webcontrols:32185| Date: Mon, 2 Jan 2006 12:47:48 -0600 | Lines: 330 | X-Priority: 3 | X-MSMail-Priority: Normal | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670 | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 | X-RFC2646: Format=Flowed; Response | Message-ID: <O11zqO#DGHA.1***@tk2msftngp13.phx.gbl> | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols | NNTP-Posting-Host: ip24-255-143-36.ks.ks.cox.net 24.255.143.36 | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl | Xref: TK2MSFTNGXA02.phx.gbl Show quoteHide quote | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols (~/CrossPost/Step1.aspx)'s| | Steven- | | Okay, I do have a theory question. What happens if/when I need to move | through the web site non-linear? The Reference Page means that it has to go | sequentially; however, I can foresee times where I'd want to allow the user | to go back and forth along the steps. Can you still make the variables | public and call them or would I need to place the information into a session | each page hop, then do a verification on the final "step"? | | Thanks! | | -David | | -- | David R. Longnecker | CCNA, MCSA, Network+, A+ | Management Information Services | Wichita Public Schools, USD 259 | | | "David R. Longnecker" <dlongnecker@community.nospam> wrote in message | news:Og%23%23w5yDGHA.3528@TK2MSFTNGP12.phx.gbl... | > Steven- | > | > From what I can tell it worked like a charm... battling a IDE issue right | > now (VS 2005 locking up with "Visual Studio is Busy" that I'm working to | > resolve right now); however, it seemed to work exactly like I needed. | > Thanks for your help! | > | > -David | > | > | > -- | > David R. Longnecker | > CCNA, MCSA, Network+, A+ | > Management Information Services | > Wichita Public Schools, USD 259 | > | > | > "Steven Cheng[MSFT]" <stch***@online.microsoft.com> wrote in message | > news:41i6gIGDGHA.1240@TK2MSFTNGXA02.phx.gbl... | >> Hi David, | >> | >> Have you got the issue resolved or does my last reply helps you a little? | >> If there're anything else we can help, please feel free to post here. | >> | >> Regards, | >> | >> Steven Cheng | >> Microsoft Online Support | >> | >> Get Secure! www.microsoft.com/security | >> (This posting is provided "AS IS", with no warranties, and confers no | >> rights.) | >> -------------------- | >> | X-Tomcat-ID: 121575119 | >> | References: <u9vaURrCGHA.***@TK2MSFTNGP14.phx.gbl> | >> | MIME-Version: 1.0 | >> | Content-Type: text/plain | >> | Content-Transfer-Encoding: 7bit | >> | From: stch***@online.microsoft.com (Steven Cheng[MSFT]) | >> | Organization: Microsoft | >> | Date: Tue, 27 Dec 2005 09:18:43 GMT | >> | Subject: RE: Master Pages and Cross-Page Form Information | >> | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols | >> | Message-ID: <voh8NasCGHA.***@TK2MSFTNGXA02.phx.gbl> | >> | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols | >> | Lines: 193 | >> | Path: TK2MSFTNGXA02.phx.gbl | >> | Xref: TK2MSFTNGXA02.phx.gbl | >> microsoft.public.dotnet.framework.aspnet.webcontrols:32037 | >> | NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122 | >> | | >> | Hi David, | >> | | >> | Welcome to MSDN newsgroup. | >> | As for the querying TextBox values from Previous page when doing cross | >> page | >> | postback in asp.net 2.0, here are some of my understanding and | >> suggestion: | >> | | >> | 1. the form values did exist in the Page.Request.Form collection. | >> However, | >> | since we're using Master page, the textboxes are cotained in the | >> | ContentPlaceHolder which itself a child conttrol in the page's control | >> | structure, so to avoid naming clash, the asp.net page will generate a | >> | unique ID for all the child controsl in it (mangling their ID).... So | >> we | >> | can not use those Textboxs' original ID to query value from | >> request.Form | >> | collection. But we can printout them through the following code (to | >> confirm | >> | that they did exists..): | >> | ===================== | >> | protected void Page_Load(object sender, EventArgs e) | >> | { | >> | if (PreviousPage != null && PreviousPage.IsCrossPagePostBack) | >> | { | >> | | >> | foreach (string key in Request.Form.Keys) | >> | { | >> | Response.Write("<br>" + key + ": " | >> +Request.Form[key]); | >> | } | >> | | >> | } | >> | } | >> | ==================== | >> | | >> | | >> | 2. Actually the recommended means to retrieve Control property values | >> in | >> | Previous for cross page postback is defining some public Properties in | >> the | >> | Previous page's page class code which expose those certain controls' | >> | property.... Then, we can use those Properties in the Target page's | >> | code.... e.g: | >> | | >> | Suppose we have two pages: | >> | | >> | | >> | The first page is as below: | >> | ==========step1.aspx=========== | >> | <%@ Page Language="C#" MasterPageFile="~/CrossPost/TM.master" | >> | AutoEventWireup="true" CodeFile="Step1.aspx.cs" | >> Inherits="CrossPost_Step1" | >> | Title="Untitled Page" %> | >> | <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" | >> | Runat="Server"> | >> | <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> | >> | <br /> | >> | <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br /> | >> | <asp:Button ID="btnCrossPost" runat="server" | >> | PostBackUrl="~/CrossPost/Step2.aspx" | >> | Text="Cross Post Back" /> | >> | </asp:Content> | >> | | >> | And the codebehind is | >> | ==========step1.aspx.cs============ | >> | public partial class CrossPost_Step1 : System.Web.UI.Page | >> | { | >> | public string TextBox1Value | >> | { | >> | get | >> | { | >> | return TextBox1.Text; | >> | } | >> | } | >> | | >> | public string TextBox2Value | >> | { | >> | get | >> | { | >> | return TextBox2.Text; | >> | } | >> | } | >> | | >> | | >> | } | >> | | >> | | >> | | >> | the target page (step2.aspx)'s aspx and codebehind: | >> | | >> | =======step2.aspx============ | >> | <%@ Page Language="C#" MasterPageFile="~/CrossPost/TM.master" | >> | AutoEventWireup="true" CodeFile="Step2.aspx.cs" | >> Inherits="CrossPost_Step2" | >> | Title="Untitled Page" %> | >> | <%@ Reference Page="~/CrossPost/Step1.aspx" %> | >> | <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" | >> | Runat="Server"> | >> | </asp:Content> | >> | | >> | | >> | | >> | =====step2.aspx.cs========== | >> | | >> | protected void Page_Load(object sender, EventArgs e) | >> | { | >> | if (PreviousPage != null && PreviousPage.IsCrossPagePostBack) | >> | { | >> | | >> | CrossPost_Step1 page1 = PreviousPage as | >> CrossPost_Step1; | >> | | >> | if (page1 != null) | >> | { | >> | Response.Write("<br>" + page1.TextBox1Value); | >> | Response.Write("<br>" + page1.TextBox2Value); | >> | } | >> | | >> | } | >> | } | >> | | >> | ============================ | >> | | >> | | >> | Note that the below directive in the step2.aspx is very important: | >> | | >> | <%@ Reference Page="~/CrossPost/Step1.aspx" %> | >> | | >> | | >> | this indicate that we'll reference that page | >> | class or code in this page so that the asp.net runtime will compile http://www.asp.net/QuickStart/aspnet/doc/tipstricks/default.aspx#crosspage| >> them | >> | into same assembly so as to make them visible to each | >> other............... | >> | | >> | Some additional resource: | >> | | >> | | >> Show quoteHide quote | >> | TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl| >> | http://msdn2.microsoft.com/en-us/library/ms178139.aspx | >> | | >> | Regards, | >> | | >> | Steven Cheng | >> | Microsoft Online Support | >> | | >> | Get Secure! www.microsoft.com/security | >> | (This posting is provided "AS IS", with no warranties, and confers no | >> | rights.) | >> | | >> | | >> | | >> | | >> | | >> | -------------------- | >> | | From: "David R. Longnecker" <dlongnecker@community.nospam> | >> | | Subject: Master Pages and Cross-Page Form Information | >> | | Date: Tue, 27 Dec 2005 01:08:22 -0600 | >> | | Lines: 223 | >> | | MIME-Version: 1.0 | >> | | Content-Type: multipart/alternative; | >> | | boundary="----=_NextPart_000_0034_01C60A82.08696930" | >> | | X-Priority: 3 | >> | | X-MSMail-Priority: Normal | >> | | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 | >> | | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 | >> | | Message-ID: <u9vaURrCGHA.***@TK2MSFTNGP14.phx.gbl> | >> | | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols | >> | | NNTP-Posting-Host: ip24-255-143-36.ks.ks.cox.net 24.255.143.36 | >> | | Path: Show quoteHide quote | >> | | Xref: TK2MSFTNGXA02.phx.gbl runat="server">| >> | microsoft.public.dotnet.framework.aspnet.webcontrols:32036 | >> | | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols | >> | | | >> | | I'm slowly learning the new caveats of master pages and ASP.NET 2.0 | >> and, | >> | so far, really enjoying it. A couple of questions to help kickstart my | >> | mind from the old ASP3 days. From what I've found, 2.0's cross-page | >> | posting allows me to set a PostBackURL and then | >> Request.Form["objectName"] | >> | the information into the next page. Okay, that works up until I use | >> Master | >> | Pages for my central header/footers. Using the Master Pages, it | >> appears | >> | nothing is past to the Postback page; however, an error is not | >> generated. | >> | | For example, on page 1 (default.aspx): | >> | | -- | >> | | <%@ Page Language="C#" MasterPageFile="~/MasterPage.master" | >> | AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" | >> | Title="Untitled Page" %> | >> | | <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" | >> | Runat="Server"> | >> | | Stuff with post back: | >> | | <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> | >> | | <asp:Button ID="Button1" runat="server" | >> PostBackUrl="~/Step2.aspx" | >> | Text="Button" /> | >> | | </asp:Content> | >> | | -- | >> | | Simple enough... on the PostBack page, I want to just read what was | >> typed | >> | in that textbox. | >> | | -- | >> | | <%@ Page Language="C#" EnableViewStateMac="false" | >> | MasterPageFile="~/MasterPage.master" AutoEventWireup="true" | >> | CodeFile="Step2.aspx.cs" Inherits="Step2" Title="Untitled Page" %> | >> | | <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" | >> | Runat="Server"> | >> | | In step 1, you typed: <% Response.Write(Request.Form["TextBox1"]; %> | >> | | </asp:Content> | >> | | -- | >> | | The master page consists of the default code: | >> | | -- | >> | | <%@ 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>Untitled Page</title> | >> | | </head> | >> | | <body> | >> | | <form id="form1" runat="server"> | >> | | <div> | >> | | <asp:contentplaceholder id="ContentPlaceHolder1" Show quoteHide quote | >> | | </asp:contentplaceholder> | >> | | </div> | >> | | </form> | >> | | </body> | >> | | </html> | >> | | -- | >> | | Is there something about the master page that I'm missing? | >> | | Any good references/resources to using master pages would also be | >> | appreciated. :) I have no trouble fishing for it, however, today, not | >> only | >> | were the fish gone, but the pond was dry. | >> | | Thanks in advance! | >> | | -David | >> | | | >> | | | >> -------------------------------------------------------------------------- | >> | | David R. Longnecker | >> | | CCNA, MCSA, Network+, A+ | >> | | Management Information Services | >> | | Wichita Public Schools, USD 259 | >> | | | >> | | | >> | | >> | | >> | > | > | | | Hi David,
Does my further response helps? If anything else we can help, please feel free to post here. Regards, Steven Cheng Microsoft Online Support Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.) -------------------- | X-Tomcat-ID: 278091478 <voh8NasCGHA.***@TK2MSFTNGXA02.phx.gbl> | References: <u9vaURrCGHA.***@TK2MSFTNGP14.phx.gbl> <41i6gIGDGHA.1***@TK2MSFTNGXA02.phx.gbl> <Og##w5yDGHA.3***@TK2MSFTNGP12.phx.gbl> <O11zqO#DGHA.1***@tk2msftngp13.phx.gbl> | MIME-Version: 1.0 microsoft.public.dotnet.framework.aspnet.webcontrols:32193| Content-Type: text/plain | Content-Transfer-Encoding: 7bit | From: stch***@online.microsoft.com (Steven Cheng[MSFT]) | Organization: Microsoft | Date: Tue, 03 Jan 2006 09:57:17 GMT | Subject: Re: Master Pages and Cross-Page Form Information | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols | Message-ID: <LYgcbwEEGHA.1***@TK2MSFTNGXA02.phx.gbl> | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols | Lines: 343 | Path: TK2MSFTNGXA02.phx.gbl | Xref: TK2MSFTNGXA02.phx.gbl Show quoteHide quote | NNTP-Posting-Host: tomcatimport2.phx.gbl 10.201.218.182 Response.Write(Request.Form["TextBox1"]; | | Thanks for your response David, | | If you want to record such a navigation path so that the user can move | forward or backward through that path... I think using SessionState will be | prefered. CrossPage posting only make sense when the original using http | post to submit to the second page, there're also many other navigation | scenarios like Response.Redirect, clientscript redirect.... So I think | use SessionState should be the better approach to record such info(when a | certain new page is navigated....).. | | Hope helps. Thanks, | | Steven Cheng | Microsoft Online Support | | Get Secure! www.microsoft.com/security | (This posting is provided "AS IS", with no warranties, and confers no | rights.) | | | | -------------------- | | From: "David R. Longnecker" <dlongnecker@community.nospam> | | References: <u9vaURrCGHA.***@TK2MSFTNGP14.phx.gbl> | <voh8NasCGHA.***@TK2MSFTNGXA02.phx.gbl> | <41i6gIGDGHA.1***@TK2MSFTNGXA02.phx.gbl> | <Og##w5yDGHA.3***@TK2MSFTNGP12.phx.gbl> | | Subject: Re: Master Pages and Cross-Page Form Information | | Date: Mon, 2 Jan 2006 12:47:48 -0600 | | Lines: 330 | | X-Priority: 3 | | X-MSMail-Priority: Normal | | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670 | | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 | | X-RFC2646: Format=Flowed; Response | | Message-ID: <O11zqO#DGHA.1***@tk2msftngp13.phx.gbl> | | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols | | NNTP-Posting-Host: ip24-255-143-36.ks.ks.cox.net 24.255.143.36 | | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl | | Xref: TK2MSFTNGXA02.phx.gbl | microsoft.public.dotnet.framework.aspnet.webcontrols:32185 | | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols | | | | Steven- | | | | Okay, I do have a theory question. What happens if/when I need to move | | through the web site non-linear? The Reference Page means that it has to | go | | sequentially; however, I can foresee times where I'd want to allow the | user | | to go back and forth along the steps. Can you still make the variables | | public and call them or would I need to place the information into a | session | | each page hop, then do a verification on the final "step"? | | | | Thanks! | | | | -David | | | | -- | | David R. Longnecker | | CCNA, MCSA, Network+, A+ | | Management Information Services | | Wichita Public Schools, USD 259 | | | | | | "David R. Longnecker" <dlongnecker@community.nospam> wrote in message | | news:Og%23%23w5yDGHA.3528@TK2MSFTNGP12.phx.gbl... | | > Steven- | | > | | > From what I can tell it worked like a charm... battling a IDE issue | right | | > now (VS 2005 locking up with "Visual Studio is Busy" that I'm working | to | | > resolve right now); however, it seemed to work exactly like I needed. | | > Thanks for your help! | | > | | > -David | | > | | > | | > -- | | > David R. Longnecker | | > CCNA, MCSA, Network+, A+ | | > Management Information Services | | > Wichita Public Schools, USD 259 | | > | | > | | > "Steven Cheng[MSFT]" <stch***@online.microsoft.com> wrote in message | | > news:41i6gIGDGHA.1240@TK2MSFTNGXA02.phx.gbl... | | >> Hi David, | | >> | | >> Have you got the issue resolved or does my last reply helps you a | little? | | >> If there're anything else we can help, please feel free to post here. | | >> | | >> Regards, | | >> | | >> Steven Cheng | | >> Microsoft Online Support | | >> | | >> Get Secure! www.microsoft.com/security | | >> (This posting is provided "AS IS", with no warranties, and confers no | | >> rights.) | | >> -------------------- | | >> | X-Tomcat-ID: 121575119 | | >> | References: <u9vaURrCGHA.***@TK2MSFTNGP14.phx.gbl> | | >> | MIME-Version: 1.0 | | >> | Content-Type: text/plain | | >> | Content-Transfer-Encoding: 7bit | | >> | From: stch***@online.microsoft.com (Steven Cheng[MSFT]) | | >> | Organization: Microsoft | | >> | Date: Tue, 27 Dec 2005 09:18:43 GMT | | >> | Subject: RE: Master Pages and Cross-Page Form Information | | >> | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols | | >> | Message-ID: <voh8NasCGHA.***@TK2MSFTNGXA02.phx.gbl> | | >> | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols | | >> | Lines: 193 | | >> | Path: TK2MSFTNGXA02.phx.gbl | | >> | Xref: TK2MSFTNGXA02.phx.gbl | | >> microsoft.public.dotnet.framework.aspnet.webcontrols:32037 | | >> | NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122 | | >> | | | >> | Hi David, | | >> | | | >> | Welcome to MSDN newsgroup. | | >> | As for the querying TextBox values from Previous page when doing | cross | | >> page | | >> | postback in asp.net 2.0, here are some of my understanding and | | >> suggestion: | | >> | | | >> | 1. the form values did exist in the Page.Request.Form collection. | | >> However, | | >> | since we're using Master page, the textboxes are cotained in the | | >> | ContentPlaceHolder which itself a child conttrol in the page's | control | | >> | structure, so to avoid naming clash, the asp.net page will generate a | | >> | unique ID for all the child controsl in it (mangling their ID).... | So | | >> we | | >> | can not use those Textboxs' original ID to query value from | | >> request.Form | | >> | collection. But we can printout them through the following code (to | | >> confirm | | >> | that they did exists..): | | >> | ===================== | | >> | protected void Page_Load(object sender, EventArgs e) | | >> | { | | >> | if (PreviousPage != null && PreviousPage.IsCrossPagePostBack) | | >> | { | | >> | | | >> | foreach (string key in Request.Form.Keys) | | >> | { | | >> | Response.Write("<br>" + key + ": " | | >> +Request.Form[key]); | | >> | } | | >> | | | >> | } | | >> | } | | >> | ==================== | | >> | | | >> | | | >> | 2. Actually the recommended means to retrieve Control property | values | | >> in | | >> | Previous for cross page postback is defining some public Properties | in | | >> the | | >> | Previous page's page class code which expose those certain controls' | | >> | property.... Then, we can use those Properties in the Target page's | | >> | code.... e.g: | | >> | | | >> | Suppose we have two pages: | | >> | | | >> | | | >> | The first page is as below: | | >> | ==========step1.aspx=========== | | >> | <%@ Page Language="C#" MasterPageFile="~/CrossPost/TM.master" | | >> | AutoEventWireup="true" CodeFile="Step1.aspx.cs" | | >> Inherits="CrossPost_Step1" | | >> | Title="Untitled Page" %> | | >> | <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" | | >> | Runat="Server"> | | >> | <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> | | >> | <br /> | | >> | <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br /> | | >> | <asp:Button ID="btnCrossPost" runat="server" | | >> | PostBackUrl="~/CrossPost/Step2.aspx" | | >> | Text="Cross Post Back" /> | | >> | </asp:Content> | | >> | | | >> | And the codebehind is | | >> | ==========step1.aspx.cs============ | | >> | public partial class CrossPost_Step1 : System.Web.UI.Page | | >> | { | | >> | public string TextBox1Value | | >> | { | | >> | get | | >> | { | | >> | return TextBox1.Text; | | >> | } | | >> | } | | >> | | | >> | public string TextBox2Value | | >> | { | | >> | get | | >> | { | | >> | return TextBox2.Text; | | >> | } | | >> | } | | >> | | | >> | | | >> | } | | >> | | | >> | | | >> | | | >> | the target page (step2.aspx)'s aspx and codebehind: | | >> | | | >> | =======step2.aspx============ | | >> | <%@ Page Language="C#" MasterPageFile="~/CrossPost/TM.master" | | >> | AutoEventWireup="true" CodeFile="Step2.aspx.cs" | | >> Inherits="CrossPost_Step2" | | >> | Title="Untitled Page" %> | | >> | <%@ Reference Page="~/CrossPost/Step1.aspx" %> | | >> | <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" | | >> | Runat="Server"> | | >> | </asp:Content> | | >> | | | >> | | | >> | | | >> | =====step2.aspx.cs========== | | >> | | | >> | protected void Page_Load(object sender, EventArgs e) | | >> | { | | >> | if (PreviousPage != null && PreviousPage.IsCrossPagePostBack) | | >> | { | | >> | | | >> | CrossPost_Step1 page1 = PreviousPage as | | >> CrossPost_Step1; | | >> | | | >> | if (page1 != null) | | >> | { | | >> | Response.Write("<br>" + page1.TextBox1Value); | | >> | Response.Write("<br>" + page1.TextBox2Value); | | >> | } | | >> | | | >> | } | | >> | } | | >> | | | >> | ============================ | | >> | | | >> | | | >> | Note that the below directive in the step2.aspx is very important: | | >> | | | >> | <%@ Reference Page="~/CrossPost/Step1.aspx" %> | | >> | | | >> | | | >> | this indicate that we'll reference that page | (~/CrossPost/Step1.aspx)'s | | >> | class or code in this page so that the asp.net runtime will compile | | >> them | | >> | into same assembly so as to make them visible to each | | >> other............... | | >> | | | >> | Some additional resource: | | >> | | | >> | | | >> | http://www.asp.net/QuickStart/aspnet/doc/tipstricks/default.aspx#crosspage | | >> | | | >> | http://msdn2.microsoft.com/en-us/library/ms178139.aspx | | >> | | | >> | Regards, | | >> | | | >> | Steven Cheng | | >> | Microsoft Online Support | | >> | | | >> | Get Secure! www.microsoft.com/security | | >> | (This posting is provided "AS IS", with no warranties, and confers no | | >> | rights.) | | >> | | | >> | | | >> | | | >> | | | >> | | | >> | -------------------- | | >> | | From: "David R. Longnecker" <dlongnecker@community.nospam> | | >> | | Subject: Master Pages and Cross-Page Form Information | | >> | | Date: Tue, 27 Dec 2005 01:08:22 -0600 | | >> | | Lines: 223 | | >> | | MIME-Version: 1.0 | | >> | | Content-Type: multipart/alternative; | | >> | | boundary="----=_NextPart_000_0034_01C60A82.08696930" | | >> | | X-Priority: 3 | | >> | | X-MSMail-Priority: Normal | | >> | | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 | | >> | | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 | | >> | | Message-ID: <u9vaURrCGHA.***@TK2MSFTNGP14.phx.gbl> | | >> | | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols | | >> | | NNTP-Posting-Host: ip24-255-143-36.ks.ks.cox.net 24.255.143.36 | | >> | | Path: | TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl | | >> | | Xref: TK2MSFTNGXA02.phx.gbl | | >> | microsoft.public.dotnet.framework.aspnet.webcontrols:32036 | | >> | | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols | | >> | | | | >> | | I'm slowly learning the new caveats of master pages and ASP.NET 2.0 | | >> and, | | >> | so far, really enjoying it. A couple of questions to help kickstart | my | | >> | mind from the old ASP3 days. From what I've found, 2.0's cross-page | | >> | posting allows me to set a PostBackURL and then | | >> Request.Form["objectName"] | | >> | the information into the next page. Okay, that works up until I use | | >> Master | | >> | Pages for my central header/footers. Using the Master Pages, it | | >> appears | | >> | nothing is past to the Postback page; however, an error is not | | >> generated. | | >> | | For example, on page 1 (default.aspx): | | >> | | -- | | >> | | <%@ Page Language="C#" MasterPageFile="~/MasterPage.master" | | >> | AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" | | >> | Title="Untitled Page" %> | | >> | | <asp:Content ID="Content1" | ContentPlaceHolderID="ContentPlaceHolder1" | | >> | Runat="Server"> | | >> | | Stuff with post back: | | >> | | <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> | | >> | | <asp:Button ID="Button1" runat="server" | | >> PostBackUrl="~/Step2.aspx" | | >> | Text="Button" /> | | >> | | </asp:Content> | | >> | | -- | | >> | | Simple enough... on the PostBack page, I want to just read what was | | >> typed | | >> | in that textbox. | | >> | | -- | | >> | | <%@ Page Language="C#" EnableViewStateMac="false" | | >> | MasterPageFile="~/MasterPage.master" AutoEventWireup="true" | | >> | CodeFile="Step2.aspx.cs" Inherits="Step2" Title="Untitled Page" %> | | >> | | <asp:Content ID="Content1" | ContentPlaceHolderID="ContentPlaceHolder1" | | >> | Runat="Server"> | | >> | | In step 1, you typed: <% Show quoteHide quote | %> | | >> | | </asp:Content> | | >> | | -- | | >> | | The master page consists of the default code: | | >> | | -- | | >> | | <%@ 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>Untitled Page</title> | | >> | | </head> | | >> | | <body> | | >> | | <form id="form1" runat="server"> | | >> | | <div> | | >> | | <asp:contentplaceholder id="ContentPlaceHolder1" | runat="server"> | | >> | | </asp:contentplaceholder> | | >> | | </div> | | >> | | </form> | | >> | | </body> | | >> | | </html> | | >> | | -- | | >> | | Is there something about the master page that I'm missing? | | >> | | Any good references/resources to using master pages would also be | | >> | appreciated. :) I have no trouble fishing for it, however, today, | not | | >> only | | >> | were the fish gone, but the pond was dry. | | >> | | Thanks in advance! | | >> | | -David | | >> | | | | >> | | | | >> | -------------------------------------------------------------------------- | | >> | | David R. Longnecker | | >> | | CCNA, MCSA, Network+, A+ | | >> | | Management Information Services | | >> | | Wichita Public Schools, USD 259 | | >> | | | | >> | | | | >> | | | >> | | | >> | | > | | > | | | | | | | | Steven-
Your response is great; I'm slowly working to change some of the current page into a session state and will post if any problems arise. Thanks for your help! -David Show quoteHide quote "Steven Cheng[MSFT]" <stch***@online.microsoft.com> wrote in message news:dC4RZ3dEGHA.832@TK2MSFTNGXA02.phx.gbl... > Hi David, > > Does my further response helps? If anything else we can help, please feel > free to post here. > > Regards, > > Steven Cheng > Microsoft Online Support > > Get Secure! www.microsoft.com/security > (This posting is provided "AS IS", with no warranties, and confers no > rights.) > -------------------- > | X-Tomcat-ID: 278091478 > | References: <u9vaURrCGHA.***@TK2MSFTNGP14.phx.gbl> > <voh8NasCGHA.***@TK2MSFTNGXA02.phx.gbl> > <41i6gIGDGHA.1***@TK2MSFTNGXA02.phx.gbl> > <Og##w5yDGHA.3***@TK2MSFTNGP12.phx.gbl> > <O11zqO#DGHA.1***@tk2msftngp13.phx.gbl> > | MIME-Version: 1.0 > | Content-Type: text/plain > | Content-Transfer-Encoding: 7bit > | From: stch***@online.microsoft.com (Steven Cheng[MSFT]) > | Organization: Microsoft > | Date: Tue, 03 Jan 2006 09:57:17 GMT > | Subject: Re: Master Pages and Cross-Page Form Information > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols > | Message-ID: <LYgcbwEEGHA.1***@TK2MSFTNGXA02.phx.gbl> > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols > | Lines: 343 > | Path: TK2MSFTNGXA02.phx.gbl > | Xref: TK2MSFTNGXA02.phx.gbl > microsoft.public.dotnet.framework.aspnet.webcontrols:32193 > | NNTP-Posting-Host: tomcatimport2.phx.gbl 10.201.218.182 > | > | Thanks for your response David, > | > | If you want to record such a navigation path so that the user can move > | forward or backward through that path... I think using SessionState will > be > | prefered. CrossPage posting only make sense when the original using http > | post to submit to the second page, there're also many other navigation > | scenarios like Response.Redirect, clientscript redirect.... So I think > | use SessionState should be the better approach to record such info(when > a > | certain new page is navigated....).. > | > | Hope helps. Thanks, > | > | Steven Cheng > | Microsoft Online Support > | > | Get Secure! www.microsoft.com/security > | (This posting is provided "AS IS", with no warranties, and confers no > | rights.) > | > | > | > | -------------------- > | | From: "David R. Longnecker" <dlongnecker@community.nospam> > | | References: <u9vaURrCGHA.***@TK2MSFTNGP14.phx.gbl> > | <voh8NasCGHA.***@TK2MSFTNGXA02.phx.gbl> > | <41i6gIGDGHA.1***@TK2MSFTNGXA02.phx.gbl> > | <Og##w5yDGHA.3***@TK2MSFTNGP12.phx.gbl> > | | Subject: Re: Master Pages and Cross-Page Form Information > | | Date: Mon, 2 Jan 2006 12:47:48 -0600 > | | Lines: 330 > | | X-Priority: 3 > | | X-MSMail-Priority: Normal > | | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670 > | | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 > | | X-RFC2646: Format=Flowed; Response > | | Message-ID: <O11zqO#DGHA.1***@tk2msftngp13.phx.gbl> > | | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols > | | NNTP-Posting-Host: ip24-255-143-36.ks.ks.cox.net 24.255.143.36 > | | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl > | | Xref: TK2MSFTNGXA02.phx.gbl > | microsoft.public.dotnet.framework.aspnet.webcontrols:32185 > | | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols > | | > | | Steven- > | | > | | Okay, I do have a theory question. What happens if/when I need to > move > | | through the web site non-linear? The Reference Page means that it has > to > | go > | | sequentially; however, I can foresee times where I'd want to allow the > | user > | | to go back and forth along the steps. Can you still make the > variables > | | public and call them or would I need to place the information into a > | session > | | each page hop, then do a verification on the final "step"? > | | > | | Thanks! > | | > | | -David > | | > | | -- > | | David R. Longnecker > | | CCNA, MCSA, Network+, A+ > | | Management Information Services > | | Wichita Public Schools, USD 259 > | | > | | > | | "David R. Longnecker" <dlongnecker@community.nospam> wrote in message > | | news:Og%23%23w5yDGHA.3528@TK2MSFTNGP12.phx.gbl... > | | > Steven- > | | > > | | > From what I can tell it worked like a charm... battling a IDE issue > | right > | | > now (VS 2005 locking up with "Visual Studio is Busy" that I'm > working > | to > | | > resolve right now); however, it seemed to work exactly like I > needed. > | | > Thanks for your help! > | | > > | | > -David > | | > > | | > > | | > -- > | | > David R. Longnecker > | | > CCNA, MCSA, Network+, A+ > | | > Management Information Services > | | > Wichita Public Schools, USD 259 > | | > > | | > > | | > "Steven Cheng[MSFT]" <stch***@online.microsoft.com> wrote in message > | | > news:41i6gIGDGHA.1240@TK2MSFTNGXA02.phx.gbl... > | | >> Hi David, > | | >> > | | >> Have you got the issue resolved or does my last reply helps you a > | little? > | | >> If there're anything else we can help, please feel free to post > here. > | | >> > | | >> Regards, > | | >> > | | >> Steven Cheng > | | >> Microsoft Online Support > | | >> > | | >> Get Secure! www.microsoft.com/security > | | >> (This posting is provided "AS IS", with no warranties, and confers > no > | | >> rights.) > | | >> -------------------- > | | >> | X-Tomcat-ID: 121575119 > | | >> | References: <u9vaURrCGHA.***@TK2MSFTNGP14.phx.gbl> > | | >> | MIME-Version: 1.0 > | | >> | Content-Type: text/plain > | | >> | Content-Transfer-Encoding: 7bit > | | >> | From: stch***@online.microsoft.com (Steven Cheng[MSFT]) > | | >> | Organization: Microsoft > | | >> | Date: Tue, 27 Dec 2005 09:18:43 GMT > | | >> | Subject: RE: Master Pages and Cross-Page Form Information > | | >> | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols > | | >> | Message-ID: <voh8NasCGHA.***@TK2MSFTNGXA02.phx.gbl> > | | >> | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols > | | >> | Lines: 193 > | | >> | Path: TK2MSFTNGXA02.phx.gbl > | | >> | Xref: TK2MSFTNGXA02.phx.gbl > | | >> microsoft.public.dotnet.framework.aspnet.webcontrols:32037 > | | >> | NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122 > | | >> | > | | >> | Hi David, > | | >> | > | | >> | Welcome to MSDN newsgroup. > | | >> | As for the querying TextBox values from Previous page when doing > | cross > | | >> page > | | >> | postback in asp.net 2.0, here are some of my understanding and > | | >> suggestion: > | | >> | > | | >> | 1. the form values did exist in the Page.Request.Form collection. > | | >> However, > | | >> | since we're using Master page, the textboxes are cotained in the > | | >> | ContentPlaceHolder which itself a child conttrol in the page's > | control > | | >> | structure, so to avoid naming clash, the asp.net page will > generate a > | | >> | unique ID for all the child controsl in it (mangling their > ID).... > > | So > | | >> we > | | >> | can not use those Textboxs' original ID to query value from > | | >> request.Form > | | >> | collection. But we can printout them through the following code > (to > | | >> confirm > | | >> | that they did exists..): > | | >> | ===================== > | | >> | protected void Page_Load(object sender, EventArgs e) > | | >> | { > | | >> | if (PreviousPage != null && > PreviousPage.IsCrossPagePostBack) > | | >> | { > | | >> | > | | >> | foreach (string key in Request.Form.Keys) > | | >> | { > | | >> | Response.Write("<br>" + key + ": " > | | >> +Request.Form[key]); > | | >> | } > | | >> | > | | >> | } > | | >> | } > | | >> | ==================== > | | >> | > | | >> | > | | >> | 2. Actually the recommended means to retrieve Control property > | values > | | >> in > | | >> | Previous for cross page postback is defining some public > Properties > | in > | | >> the > | | >> | Previous page's page class code which expose those certain > controls' > | | >> | property.... Then, we can use those Properties in the Target > page's > | | >> | code.... e.g: > | | >> | > | | >> | Suppose we have two pages: > | | >> | > | | >> | > | | >> | The first page is as below: > | | >> | ==========step1.aspx=========== > | | >> | <%@ Page Language="C#" MasterPageFile="~/CrossPost/TM.master" > | | >> | AutoEventWireup="true" CodeFile="Step1.aspx.cs" > | | >> Inherits="CrossPost_Step1" > | | >> | Title="Untitled Page" %> > | | >> | <asp:Content ID="Content1" > ContentPlaceHolderID="ContentPlaceHolder1" > | | >> | Runat="Server"> > | | >> | <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> > | | >> | <br /> > | | >> | <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br > /> > | | >> | <asp:Button ID="btnCrossPost" runat="server" > | | >> | PostBackUrl="~/CrossPost/Step2.aspx" > | | >> | Text="Cross Post Back" /> > | | >> | </asp:Content> > | | >> | > | | >> | And the codebehind is > | | >> | ==========step1.aspx.cs============ > | | >> | public partial class CrossPost_Step1 : System.Web.UI.Page > | | >> | { > | | >> | public string TextBox1Value > | | >> | { > | | >> | get > | | >> | { > | | >> | return TextBox1.Text; > | | >> | } > | | >> | } > | | >> | > | | >> | public string TextBox2Value > | | >> | { > | | >> | get > | | >> | { > | | >> | return TextBox2.Text; > | | >> | } > | | >> | } > | | >> | > | | >> | > | | >> | } > | | >> | > | | >> | > | | >> | > | | >> | the target page (step2.aspx)'s aspx and codebehind: > | | >> | > | | >> | =======step2.aspx============ > | | >> | <%@ Page Language="C#" MasterPageFile="~/CrossPost/TM.master" > | | >> | AutoEventWireup="true" CodeFile="Step2.aspx.cs" > | | >> Inherits="CrossPost_Step2" > | | >> | Title="Untitled Page" %> > | | >> | <%@ Reference Page="~/CrossPost/Step1.aspx" %> > | | >> | <asp:Content ID="Content1" > ContentPlaceHolderID="ContentPlaceHolder1" > | | >> | Runat="Server"> > | | >> | </asp:Content> > | | >> | > | | >> | > | | >> | > | | >> | =====step2.aspx.cs========== > | | >> | > | | >> | protected void Page_Load(object sender, EventArgs e) > | | >> | { > | | >> | if (PreviousPage != null && > PreviousPage.IsCrossPagePostBack) > | | >> | { > | | >> | > | | >> | CrossPost_Step1 page1 = PreviousPage as > | | >> CrossPost_Step1; > | | >> | > | | >> | if (page1 != null) > | | >> | { > | | >> | Response.Write("<br>" + page1.TextBox1Value); > | | >> | Response.Write("<br>" + page1.TextBox2Value); > | | >> | } > | | >> | > | | >> | } > | | >> | } > | | >> | > | | >> | ============================ > | | >> | > | | >> | > | | >> | Note that the below directive in the step2.aspx is very > important: > | | >> | > | | >> | <%@ Reference Page="~/CrossPost/Step1.aspx" %> > | | >> | > | | >> | > | | >> | this indicate that we'll reference that page > | (~/CrossPost/Step1.aspx)'s > | | >> | class or code in this page so that the asp.net runtime will > compile > | | >> them > | | >> | into same assembly so as to make them visible to each > | | >> other............... > | | >> | > | | >> | Some additional resource: > | | >> | > | | >> | > | | >> > | > http://www.asp.net/QuickStart/aspnet/doc/tipstricks/default.aspx#crosspage > | | >> | > | | >> | http://msdn2.microsoft.com/en-us/library/ms178139.aspx > | | >> | > | | >> | Regards, > | | >> | > | | >> | Steven Cheng > | | >> | Microsoft Online Support > | | >> | > | | >> | Get Secure! www.microsoft.com/security > | | >> | (This posting is provided "AS IS", with no warranties, and > confers > no > | | >> | rights.) > | | >> | > | | >> | > | | >> | > | | >> | > | | >> | > | | >> | -------------------- > | | >> | | From: "David R. Longnecker" <dlongnecker@community.nospam> > | | >> | | Subject: Master Pages and Cross-Page Form Information > | | >> | | Date: Tue, 27 Dec 2005 01:08:22 -0600 > | | >> | | Lines: 223 > | | >> | | MIME-Version: 1.0 > | | >> | | Content-Type: multipart/alternative; > | | >> | | boundary="----=_NextPart_000_0034_01C60A82.08696930" > | | >> | | X-Priority: 3 > | | >> | | X-MSMail-Priority: Normal > | | >> | | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 > | | >> | | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 > | | >> | | Message-ID: <u9vaURrCGHA.***@TK2MSFTNGP14.phx.gbl> > | | >> | | Newsgroups: > microsoft.public.dotnet.framework.aspnet.webcontrols > | | >> | | NNTP-Posting-Host: ip24-255-143-36.ks.ks.cox.net 24.255.143.36 > | | >> | | Path: > | TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl > | | >> | | Xref: TK2MSFTNGXA02.phx.gbl > | | >> | microsoft.public.dotnet.framework.aspnet.webcontrols:32036 > | | >> | | X-Tomcat-NG: > microsoft.public.dotnet.framework.aspnet.webcontrols > | | >> | | > | | >> | | I'm slowly learning the new caveats of master pages and ASP.NET > 2.0 > | | >> and, > | | >> | so far, really enjoying it. A couple of questions to help > kickstart > | my > | | >> | mind from the old ASP3 days. From what I've found, 2.0's > cross-page > | | >> | posting allows me to set a PostBackURL and then > | | >> Request.Form["objectName"] > | | >> | the information into the next page. Okay, that works up until I > use > | | >> Master > | | >> | Pages for my central header/footers. Using the Master Pages, it > | | >> appears > | | >> | nothing is past to the Postback page; however, an error is not > | | >> generated. > | | >> | | For example, on page 1 (default.aspx): > | | >> | | -- > | | >> | | <%@ Page Language="C#" MasterPageFile="~/MasterPage.master" > | | >> | AutoEventWireup="true" CodeFile="Default.aspx.cs" > Inherits="_Default" > | | >> | Title="Untitled Page" %> > | | >> | | <asp:Content ID="Content1" > | ContentPlaceHolderID="ContentPlaceHolder1" > | | >> | Runat="Server"> > | | >> | | Stuff with post back: > | | >> | | <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> > | | >> | | <asp:Button ID="Button1" runat="server" > | | >> PostBackUrl="~/Step2.aspx" > | | >> | Text="Button" /> > | | >> | | </asp:Content> > | | >> | | -- > | | >> | | Simple enough... on the PostBack page, I want to just read what > was > | | >> typed > | | >> | in that textbox. > | | >> | | -- > | | >> | | <%@ Page Language="C#" EnableViewStateMac="false" > | | >> | MasterPageFile="~/MasterPage.master" AutoEventWireup="true" > | | >> | CodeFile="Step2.aspx.cs" Inherits="Step2" Title="Untitled Page" > %> > | | >> | | <asp:Content ID="Content1" > | ContentPlaceHolderID="ContentPlaceHolder1" > | | >> | Runat="Server"> > | | >> | | In step 1, you typed: <% > Response.Write(Request.Form["TextBox1"]; > | %> > | | >> | | </asp:Content> > | | >> | | -- > | | >> | | The master page consists of the default code: > | | >> | | -- > | | >> | | <%@ 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>Untitled Page</title> > | | >> | | </head> > | | >> | | <body> > | | >> | | <form id="form1" runat="server"> > | | >> | | <div> > | | >> | | <asp:contentplaceholder id="ContentPlaceHolder1" > | runat="server"> > | | >> | | </asp:contentplaceholder> > | | >> | | </div> > | | >> | | </form> > | | >> | | </body> > | | >> | | </html> > | | >> | | -- > | | >> | | Is there something about the master page that I'm missing? > | | >> | | Any good references/resources to using master pages would also > be > | | >> | appreciated. :) I have no trouble fishing for it, however, > today, > | not > | | >> only > | | >> | were the fish gone, but the pond was dry. > | | >> | | Thanks in advance! > | | >> | | -David > | | >> | | > | | >> | | > | | >> > | -------------------------------------------------------------------------- > | | >> | | David R. Longnecker > | | >> | | CCNA, MCSA, Network+, A+ > | | >> | | Management Information Services > | | >> | | Wichita Public Schools, USD 259 > | | >> | | > | | >> | | > | | >> | > | | >> | > | | >> > | | > > | | > > | | > | | > | | > | > | > You're welcome Dave,
Good luck! Steven Cheng Microsoft Online Support Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.) -------------------- | From: "David R. Longnecker" <dlongnecker@community.nospam> <voh8NasCGHA.***@TK2MSFTNGXA02.phx.gbl> | References: <u9vaURrCGHA.***@TK2MSFTNGP14.phx.gbl> <41i6gIGDGHA.1***@TK2MSFTNGXA02.phx.gbl> <Og##w5yDGHA.3***@TK2MSFTNGP12.phx.gbl> <O11zqO#DGHA.1***@tk2msftngp13.phx.gbl> <LYgcbwEEGHA.1***@TK2MSFTNGXA02.phx.gbl> <dC4RZ3dEGHA.***@TK2MSFTNGXA02.phx.gbl> | Subject: Re: Master Pages and Cross-Page Form Information microsoft.public.dotnet.framework.aspnet.webcontrols:32270| Date: Thu, 5 Jan 2006 16:37:14 -0600 | Lines: 484 | X-Priority: 3 | X-MSMail-Priority: Normal | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670 | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 | X-RFC2646: Format=Flowed; Original | Message-ID: <#dzfYikEGHA.3***@TK2MSFTNGP10.phx.gbl> | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols | NNTP-Posting-Host: ip24-255-143-36.ks.ks.cox.net 24.255.143.36 | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl | Xref: TK2MSFTNGXA02.phx.gbl Show quoteHide quote | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl| | Steven- | | Your response is great; I'm slowly working to change some of the current | page into a session state and will post if any problems arise. Thanks for | your help! | | -David | | "Steven Cheng[MSFT]" <stch***@online.microsoft.com> wrote in message | news:dC4RZ3dEGHA.832@TK2MSFTNGXA02.phx.gbl... | > Hi David, | > | > Does my further response helps? If anything else we can help, please feel | > free to post here. | > | > Regards, | > | > Steven Cheng | > Microsoft Online Support | > | > Get Secure! www.microsoft.com/security | > (This posting is provided "AS IS", with no warranties, and confers no | > rights.) | > -------------------- | > | X-Tomcat-ID: 278091478 | > | References: <u9vaURrCGHA.***@TK2MSFTNGP14.phx.gbl> | > <voh8NasCGHA.***@TK2MSFTNGXA02.phx.gbl> | > <41i6gIGDGHA.1***@TK2MSFTNGXA02.phx.gbl> | > <Og##w5yDGHA.3***@TK2MSFTNGP12.phx.gbl> | > <O11zqO#DGHA.1***@tk2msftngp13.phx.gbl> | > | MIME-Version: 1.0 | > | Content-Type: text/plain | > | Content-Transfer-Encoding: 7bit | > | From: stch***@online.microsoft.com (Steven Cheng[MSFT]) | > | Organization: Microsoft | > | Date: Tue, 03 Jan 2006 09:57:17 GMT | > | Subject: Re: Master Pages and Cross-Page Form Information | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols | > | Message-ID: <LYgcbwEEGHA.1***@TK2MSFTNGXA02.phx.gbl> | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols | > | Lines: 343 | > | Path: TK2MSFTNGXA02.phx.gbl | > | Xref: TK2MSFTNGXA02.phx.gbl | > microsoft.public.dotnet.framework.aspnet.webcontrols:32193 | > | NNTP-Posting-Host: tomcatimport2.phx.gbl 10.201.218.182 | > | | > | Thanks for your response David, | > | | > | If you want to record such a navigation path so that the user can move | > | forward or backward through that path... I think using SessionState will | > be | > | prefered. CrossPage posting only make sense when the original using http | > | post to submit to the second page, there're also many other navigation | > | scenarios like Response.Redirect, clientscript redirect.... So I think | > | use SessionState should be the better approach to record such info(when | > a | > | certain new page is navigated....).. | > | | > | Hope helps. Thanks, | > | | > | Steven Cheng | > | Microsoft Online Support | > | | > | Get Secure! www.microsoft.com/security | > | (This posting is provided "AS IS", with no warranties, and confers no | > | rights.) | > | | > | | > | | > | -------------------- | > | | From: "David R. Longnecker" <dlongnecker@community.nospam> | > | | References: <u9vaURrCGHA.***@TK2MSFTNGP14.phx.gbl> | > | <voh8NasCGHA.***@TK2MSFTNGXA02.phx.gbl> | > | <41i6gIGDGHA.1***@TK2MSFTNGXA02.phx.gbl> | > | <Og##w5yDGHA.3***@TK2MSFTNGP12.phx.gbl> | > | | Subject: Re: Master Pages and Cross-Page Form Information | > | | Date: Mon, 2 Jan 2006 12:47:48 -0600 | > | | Lines: 330 | > | | X-Priority: 3 | > | | X-MSMail-Priority: Normal | > | | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670 | > | | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 | > | | X-RFC2646: Format=Flowed; Response | > | | Message-ID: <O11zqO#DGHA.1***@tk2msftngp13.phx.gbl> | > | | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols | > | | NNTP-Posting-Host: ip24-255-143-36.ks.ks.cox.net 24.255.143.36 | > | | Path: Show quoteHide quote | > | | Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.framework.aspnet.webcontrols| > | microsoft.public.dotnet.framework.aspnet.webcontrols:32185 | > | | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols | > | | | > | | Steven- | > | | | > | | Okay, I do have a theory question. What happens if/when I need to | > move | > | | through the web site non-linear? The Reference Page means that it has | > to | > | go | > | | sequentially; however, I can foresee times where I'd want to allow the | > | user | > | | to go back and forth along the steps. Can you still make the | > variables | > | | public and call them or would I need to place the information into a | > | session | > | | each page hop, then do a verification on the final "step"? | > | | | > | | Thanks! | > | | | > | | -David | > | | | > | | -- | > | | David R. Longnecker | > | | CCNA, MCSA, Network+, A+ | > | | Management Information Services | > | | Wichita Public Schools, USD 259 | > | | | > | | | > | | "David R. Longnecker" <dlongnecker@community.nospam> wrote in message | > | | news:Og%23%23w5yDGHA.3528@TK2MSFTNGP12.phx.gbl... | > | | > Steven- | > | | > | > | | > From what I can tell it worked like a charm... battling a IDE issue | > | right | > | | > now (VS 2005 locking up with "Visual Studio is Busy" that I'm | > working | > | to | > | | > resolve right now); however, it seemed to work exactly like I | > needed. | > | | > Thanks for your help! | > | | > | > | | > -David | > | | > | > | | > | > | | > -- | > | | > David R. Longnecker | > | | > CCNA, MCSA, Network+, A+ | > | | > Management Information Services | > | | > Wichita Public Schools, USD 259 | > | | > | > | | > | > | | > "Steven Cheng[MSFT]" <stch***@online.microsoft.com> wrote in message | > | | > news:41i6gIGDGHA.1240@TK2MSFTNGXA02.phx.gbl... | > | | >> Hi David, | > | | >> | > | | >> Have you got the issue resolved or does my last reply helps you a | > | little? | > | | >> If there're anything else we can help, please feel free to post | > here. | > | | >> | > | | >> Regards, | > | | >> | > | | >> Steven Cheng | > | | >> Microsoft Online Support | > | | >> | > | | >> Get Secure! www.microsoft.com/security | > | | >> (This posting is provided "AS IS", with no warranties, and confers | > no | > | | >> rights.) | > | | >> -------------------- | > | | >> | X-Tomcat-ID: 121575119 | > | | >> | References: <u9vaURrCGHA.***@TK2MSFTNGP14.phx.gbl> | > | | >> | MIME-Version: 1.0 | > | | >> | Content-Type: text/plain | > | | >> | Content-Transfer-Encoding: 7bit | > | | >> | From: stch***@online.microsoft.com (Steven Cheng[MSFT]) | > | | >> | Organization: Microsoft | > | | >> | Date: Tue, 27 Dec 2005 09:18:43 GMT | > | | >> | Subject: RE: Master Pages and Cross-Page Form Information | > | | >> | X-Tomcat-NG: | > | | >> | Message-ID: <voh8NasCGHA.***@TK2MSFTNGXA02.phx.gbl> microsoft.public.dotnet.framework.aspnet.webcontrols| > | | >> | Newsgroups: Show quoteHide quote | > | | >> | Lines: 193 runat="server"></asp:TextBox><br | > | | >> | Path: TK2MSFTNGXA02.phx.gbl | > | | >> | Xref: TK2MSFTNGXA02.phx.gbl | > | | >> microsoft.public.dotnet.framework.aspnet.webcontrols:32037 | > | | >> | NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122 | > | | >> | | > | | >> | Hi David, | > | | >> | | > | | >> | Welcome to MSDN newsgroup. | > | | >> | As for the querying TextBox values from Previous page when doing | > | cross | > | | >> page | > | | >> | postback in asp.net 2.0, here are some of my understanding and | > | | >> suggestion: | > | | >> | | > | | >> | 1. the form values did exist in the Page.Request.Form collection. | > | | >> However, | > | | >> | since we're using Master page, the textboxes are cotained in the | > | | >> | ContentPlaceHolder which itself a child conttrol in the page's | > | control | > | | >> | structure, so to avoid naming clash, the asp.net page will | > generate a | > | | >> | unique ID for all the child controsl in it (mangling their | > ID).... | > | > | So | > | | >> we | > | | >> | can not use those Textboxs' original ID to query value from | > | | >> request.Form | > | | >> | collection. But we can printout them through the following code | > (to | > | | >> confirm | > | | >> | that they did exists..): | > | | >> | ===================== | > | | >> | protected void Page_Load(object sender, EventArgs e) | > | | >> | { | > | | >> | if (PreviousPage != null && | > PreviousPage.IsCrossPagePostBack) | > | | >> | { | > | | >> | | > | | >> | foreach (string key in Request.Form.Keys) | > | | >> | { | > | | >> | Response.Write("<br>" + key + ": " | > | | >> +Request.Form[key]); | > | | >> | } | > | | >> | | > | | >> | } | > | | >> | } | > | | >> | ==================== | > | | >> | | > | | >> | | > | | >> | 2. Actually the recommended means to retrieve Control property | > | values | > | | >> in | > | | >> | Previous for cross page postback is defining some public | > Properties | > | in | > | | >> the | > | | >> | Previous page's page class code which expose those certain | > controls' | > | | >> | property.... Then, we can use those Properties in the Target | > page's | > | | >> | code.... e.g: | > | | >> | | > | | >> | Suppose we have two pages: | > | | >> | | > | | >> | | > | | >> | The first page is as below: | > | | >> | ==========step1.aspx=========== | > | | >> | <%@ Page Language="C#" MasterPageFile="~/CrossPost/TM.master" | > | | >> | AutoEventWireup="true" CodeFile="Step1.aspx.cs" | > | | >> Inherits="CrossPost_Step1" | > | | >> | Title="Untitled Page" %> | > | | >> | <asp:Content ID="Content1" | > ContentPlaceHolderID="ContentPlaceHolder1" | > | | >> | Runat="Server"> | > | | >> | <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> | > | | >> | <br /> | > | | >> | <asp:TextBox ID="TextBox2" Show quoteHide quote | > /> http://www.asp.net/QuickStart/aspnet/doc/tipstricks/default.aspx#crosspage| > | | >> | <asp:Button ID="btnCrossPost" runat="server" | > | | >> | PostBackUrl="~/CrossPost/Step2.aspx" | > | | >> | Text="Cross Post Back" /> | > | | >> | </asp:Content> | > | | >> | | > | | >> | And the codebehind is | > | | >> | ==========step1.aspx.cs============ | > | | >> | public partial class CrossPost_Step1 : System.Web.UI.Page | > | | >> | { | > | | >> | public string TextBox1Value | > | | >> | { | > | | >> | get | > | | >> | { | > | | >> | return TextBox1.Text; | > | | >> | } | > | | >> | } | > | | >> | | > | | >> | public string TextBox2Value | > | | >> | { | > | | >> | get | > | | >> | { | > | | >> | return TextBox2.Text; | > | | >> | } | > | | >> | } | > | | >> | | > | | >> | | > | | >> | } | > | | >> | | > | | >> | | > | | >> | | > | | >> | the target page (step2.aspx)'s aspx and codebehind: | > | | >> | | > | | >> | =======step2.aspx============ | > | | >> | <%@ Page Language="C#" MasterPageFile="~/CrossPost/TM.master" | > | | >> | AutoEventWireup="true" CodeFile="Step2.aspx.cs" | > | | >> Inherits="CrossPost_Step2" | > | | >> | Title="Untitled Page" %> | > | | >> | <%@ Reference Page="~/CrossPost/Step1.aspx" %> | > | | >> | <asp:Content ID="Content1" | > ContentPlaceHolderID="ContentPlaceHolder1" | > | | >> | Runat="Server"> | > | | >> | </asp:Content> | > | | >> | | > | | >> | | > | | >> | | > | | >> | =====step2.aspx.cs========== | > | | >> | | > | | >> | protected void Page_Load(object sender, EventArgs e) | > | | >> | { | > | | >> | if (PreviousPage != null && | > PreviousPage.IsCrossPagePostBack) | > | | >> | { | > | | >> | | > | | >> | CrossPost_Step1 page1 = PreviousPage as | > | | >> CrossPost_Step1; | > | | >> | | > | | >> | if (page1 != null) | > | | >> | { | > | | >> | Response.Write("<br>" + page1.TextBox1Value); | > | | >> | Response.Write("<br>" + page1.TextBox2Value); | > | | >> | } | > | | >> | | > | | >> | } | > | | >> | } | > | | >> | | > | | >> | ============================ | > | | >> | | > | | >> | | > | | >> | Note that the below directive in the step2.aspx is very | > important: | > | | >> | | > | | >> | <%@ Reference Page="~/CrossPost/Step1.aspx" %> | > | | >> | | > | | >> | | > | | >> | this indicate that we'll reference that page | > | (~/CrossPost/Step1.aspx)'s | > | | >> | class or code in this page so that the asp.net runtime will | > compile | > | | >> them | > | | >> | into same assembly so as to make them visible to each | > | | >> other............... | > | | >> | | > | | >> | Some additional resource: | > | | >> | | > | | >> | | > | | >> | > | | > Show quoteHide quote | > | | >> | 24.255.143.36| > | | >> | http://msdn2.microsoft.com/en-us/library/ms178139.aspx | > | | >> | | > | | >> | Regards, | > | | >> | | > | | >> | Steven Cheng | > | | >> | Microsoft Online Support | > | | >> | | > | | >> | Get Secure! www.microsoft.com/security | > | | >> | (This posting is provided "AS IS", with no warranties, and | > confers | > no | > | | >> | rights.) | > | | >> | | > | | >> | | > | | >> | | > | | >> | | > | | >> | | > | | >> | -------------------- | > | | >> | | From: "David R. Longnecker" <dlongnecker@community.nospam> | > | | >> | | Subject: Master Pages and Cross-Page Form Information | > | | >> | | Date: Tue, 27 Dec 2005 01:08:22 -0600 | > | | >> | | Lines: 223 | > | | >> | | MIME-Version: 1.0 | > | | >> | | Content-Type: multipart/alternative; | > | | >> | | boundary="----=_NextPart_000_0034_01C60A82.08696930" | > | | >> | | X-Priority: 3 | > | | >> | | X-MSMail-Priority: Normal | > | | >> | | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 | > | | >> | | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 | > | | >> | | Message-ID: <u9vaURrCGHA.***@TK2MSFTNGP14.phx.gbl> | > | | >> | | Newsgroups: | > microsoft.public.dotnet.framework.aspnet.webcontrols | > | | >> | | NNTP-Posting-Host: ip24-255-143-36.ks.ks.cox.net Show quoteHide quote | > | | >> | | Path: | > | TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl | > | | >> | | Xref: TK2MSFTNGXA02.phx.gbl | > | | >> | microsoft.public.dotnet.framework.aspnet.webcontrols:32036 | > | | >> | | X-Tomcat-NG: | > microsoft.public.dotnet.framework.aspnet.webcontrols | > | | >> | | | > | | >> | | I'm slowly learning the new caveats of master pages and ASP.NET | > 2.0 | > | | >> and, | > | | >> | so far, really enjoying it. A couple of questions to help | > kickstart | > | my | > | | >> | mind from the old ASP3 days. From what I've found, 2.0's | > cross-page | > | | >> | posting allows me to set a PostBackURL and then | > | | >> Request.Form["objectName"] | > | | >> | the information into the next page. Okay, that works up until I | > use | > | | >> Master | > | | >> | Pages for my central header/footers. Using the Master Pages, it | > | | >> appears | > | | >> | nothing is past to the Postback page; however, an error is not | > | | >> generated. | > | | >> | | For example, on page 1 (default.aspx): | > | | >> | | -- | > | | >> | | <%@ Page Language="C#" MasterPageFile="~/MasterPage.master" | > | | >> | AutoEventWireup="true" CodeFile="Default.aspx.cs" | > Inherits="_Default" | > | | >> | Title="Untitled Page" %> | > | | >> | | <asp:Content ID="Content1" | > | ContentPlaceHolderID="ContentPlaceHolder1" | > | | >> | Runat="Server"> | > | | >> | | Stuff with post back: | > | | >> | | <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> | > | | >> | | <asp:Button ID="Button1" runat="server" | > | | >> PostBackUrl="~/Step2.aspx" | > | | >> | Text="Button" /> | > | | >> | | </asp:Content> | > | | >> | | -- | > | | >> | | Simple enough... on the PostBack page, I want to just read what | > was | > | | >> typed | > | | >> | in that textbox. | > | | >> | | -- | > | | >> | | <%@ Page Language="C#" EnableViewStateMac="false" | > | | >> | MasterPageFile="~/MasterPage.master" AutoEventWireup="true" | > | | >> | CodeFile="Step2.aspx.cs" Inherits="Step2" Title="Untitled Page" | > %> | > | | >> | | <asp:Content ID="Content1" | > | ContentPlaceHolderID="ContentPlaceHolder1" | > | | >> | Runat="Server"> | > | | >> | | In step 1, you typed: <% | > Response.Write(Request.Form["TextBox1"]; | > | %> | > | | >> | | </asp:Content> | > | | >> | | -- | > | | >> | | The master page consists of the default code: | > | | >> | | -- | > | | >> | | <%@ 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>Untitled Page</title> | > | | >> | | </head> | > | | >> | | <body> | > | | >> | | <form id="form1" runat="server"> | > | | >> | | <div> | > | | >> | | <asp:contentplaceholder id="ContentPlaceHolder1" | > | runat="server"> | > | | >> | | </asp:contentplaceholder> | > | | >> | | </div> | > | | >> | | </form> | > | | >> | | </body> | > | | >> | | </html> | > | | >> | | -- | > | | >> | | Is there something about the master page that I'm missing? | > | | >> | | Any good references/resources to using master pages would also | > be | > | | >> | appreciated. :) I have no trouble fishing for it, however, | > today, | > | not | > | | >> only | > | | >> | were the fish gone, but the pond was dry. | > | | >> | | Thanks in advance! | > | | >> | | -David | > | | >> | | | > | | >> | | | > | | >> | > | -------------------------------------------------------------------------- | > | | >> | | David R. Longnecker | > | | >> | | CCNA, MCSA, Network+, A+ | > | | >> | | Management Information Services | > | | >> | | Wichita Public Schools, USD 259 | > | | >> | | | > | | >> | | | > | | >> | | > | | >> | | > | | >> | > | | > | > | | > | > | | | > | | | > | | | > | | > | | > | | |
Wizard Control and IsPostBack
Styling DetailView or FormView Click event handler not called on dynamically create image button extended Label webcontrol, doesn't populate it's children ?? Adding Access keys to menu items in the Menu control GridView: Update is just not working for me Repeater Grouping file upload control - ASP2.0 Adding DataMember support to SqlDataSource Earn money Online - without risk! |
|||||||||||||||||||||||