UpdatePanels, LinkButtons, and PostBackUrls

  • Thread starter Thread starter Nathan Sokalski
  • Start date Start date
N

Nathan Sokalski

I have an UpdatePanel that contains a LinkButton with a PostBackUrl. The
LinkButton is marked as a PostBackTrigger, so it does a full postback.
However, when it posts back, it goes straight to the page specified in the
PostBackUrl. I always thought (and the way I have always used it in the
past, where it worked) that it posted back to the page the button is on,
executed the stuff like Page_Load and the eventhandler for the button's
Click event, created the PreviousPage property, and then went to the page
specified in PostBackUrl. When using PostBackUrl, is it supposed to execute
the current page before going to the one specified in the PostBackUrl
property? Thanks.

Nathan Sokalski
(e-mail address removed)
http://www.nathansokalski.com/
 
Hi Nathan,

You might be confusing the PostBackUrl functionality with the
Server.Transfer or Response.Redirect call. The PostBackUrl functionality
actually sets the action property of the form to the specified URL, so the
browser makes the post request towards it.

To have some of the source page life cycle steps executed first, you can use
a normal postback and then either use Response.Redirect, or Server.Transfer.
You could prefer Server.Transfer if you need to access the post data from
the target page.

Cheers,
Erjan
 
That is probably true, but something I found on the web after making my
original post was that the events from the source page I mentioned
(Page_Load, Click, etc.) are executed only if the PreviousPage property is
accessed on the target page. The author of the page I got was not sure why
this was the situation, but when I added a statement to my target page that
used the PreviousPage property, these events were executed, so I guess it
does work this way. I'm sure there is a little more detail to it somewhere,
but for now, this lets me do what I want.

Nathan Sokalski
(e-mail address removed)
http://www.nathansokalski.com/
 
Back
Top