CrossPage Posting In ASP.NET 2.0 and HAndling MultiSource

Posted: December 5, 2005 in Uncategorized

As you Know the Asp.Net1.1 model was built in with Self posting that is Autopostback of forms and was a single form model although there are hooks like Paul Wilson’s multiform(i ll rather say it hooks ..hope Paul; u don’t mind .Developers from ASP Background always found this a s a limitation as they tend s to post (Submit )to a different Page .Microsoft provides few Changes in this arena to provide the facility of Crosspage posting and the Wizard control to handle such scenario an demands.

 

So how Cross page posting works: – here is the desc from the Quick start site

 

Cross page posting sets action of the form in Page 1
When the Button is clicked, the post goes from Page 1 to Page 2
Page 2 retains viewstate from Page 1

 When PreviousPage accessed, viewstate is re-populated to an instance of Page 1

 Page 1 then executes up to its LoadComplete phase (excludes rendering)

 At this point, Page 2 may access the values of controls in Page 1

 

Now for differentiating the post back and crosspage post back you can check  like (if (!Page.IsCrossPagePostBack)

{
handle a normal request here
}

Also Note that you can Postback to different Application

as well although the previouspage would be NULL here

See for the info to the quickstart site.

 

However still you can’t directly access the previous page control and you need to do like

(Textbox)Page.PreviousPage.FindControl to get the val.

 

Saying all these more question arises what happen when i need to submit (postback) to same page from multiple sources..Now how can i handle the same????

 

I am not going to provide the in-depth behavior here as Fritz and Scott Allen already had written the workarounds…

Read the same here 2 wonderful posts on the subject:-

 

Multi-source cross page posting

Design Considerations for Cross Page Post Backs in ASP.NET 2.0 

 

 

However still you can’t directly access the previous page control and you need to do like

(TextBox)Page.PreviousPage.FindControl to get the val.

 

 

ALSO you might think how you ll get the values in master pages scenario.Let say you submitted to a differnet page and now you wants to get the previous page control values.In Master pages scenario you need to first fidn the container an dthen use the findcontrol to get the value of the previous page.hope this helps

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s