determining that a Postback opens a new page
I have a page (page1) with a LinkButton that开发者_运维技巧, when clicked, will take the browser to a new page (page2).
When I click the LinkButton page1 posts back and hits the Init and Load event handlers for page1, and then moves on to page2.
How can I tell in the page1 postback that I am about to be taken to a new page, as opposed to clicking a Button that causes the page posts back but does not navigate away?
You can also add OnClick events to your code behind for each button, and in the case of the one that is to postback to another page, do a Response.Redirect. The limitation of that however is that if you need form data on "page2", you will lose posted form data on a Response.Redirect.
It appears that you're not using the OnCLick event of the LinkButton, If you use the event, perform the action of the click there, not on the Page Load event?
精彩评论