in

Dot Net Mafia

Group site for developer blogs dealing with (usually) .NET, SharePoint 2013, SharePoint 2010, Office 365, SharePoint Online, and other Microsoft products, as well as some discussion of general programming related concepts.

This Blog

Syndication

Archives

Corey Roth [MVP]

A SharePoint MVP bringing you the latest time saving tips for SharePoint 2013, SharePoint 2010, Office 365, SharePoint Online, MOSS 2007, ASP.NET, LINQ, and Visual Studio 2012.

Cross-Page Posting

This is a well known feature of ASP.NET 2.0, but I have yet to talk about how it works.  ASP.NET 2.0 now supports posting to another page (i.e.: Page1.aspx can post to Page2.aspx).  The page that is posted to can access anything from the first page (i.e.: controls, etc).  To specify a page to post back to, start by specifying a PostBackUrl on your submit button (this could be a Button, ImageButton, or LinkButton).  In the page that you post to, if you need to check to see if this is a cross-page postback, you can check the value of the IsCrossPagePostBack property in the Page class.
 
As I said earlier, you can access controls from the calling page.  Unfortunately, you have to do it through the use of FindControl(), which is why I would never be convinced to build an application with these.  The Page class has a PreviousPage property which can then be used to find the control.
if (Page.IsCrossPagePostBack)
{
      TextBox PickupLocationTextBox = 
(TextBox)Page.PreviousPage.FindControls("PickupLocationTextBox");
}
Honestly, I don't care to go through all of that to get the value of a TextBox.   If you ever have to though, that is how you can do it.

Read the complete post at http://www.dotnettipoftheday.com/blog.aspx?id=113

2012 dotnetmafia.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems