Redirect target="_blank" postback problem

  • Thread starter Thread starter JJ
  • Start date Start date
J

JJ

Hi all, I have a help page that I have to (against my better judgement) open
up in a new window, which will show the help for the current page the user is
on. So in my master page I have a bulletedlist that I populate at runtime
(so that I can put a request variable on the link in the listitem's value
property).

<asp:BulletedList runat="server" ID="lstHelp" Target="_blank"
DisplayMode="HyperLink"></asp:BulletedList>

This all works great. The problem is on pages that do postbacks. If I am
on one of these pages, click the link from above to open the help window and
then go back to the system page do the action that causes the postback it
actually postsback to the help page, instead of itself. What am I doing
wrong here? Why does it postback to the page I redirected to, rather than
itself.
 
Well this was interesting, turns out it is because the Help page used the
same master page as the page that launched it. I was doing some reading on
how asp.net handles postbacks and the idea popped into my head. So I removed
the master page from the help screen and made it a stand-alone page and
voila, the postback of the page that launced the help page posts back to
itself now.

I just looked at the __doPostBack() function that asp.net writes, it creates
a theForm variable that is the form that resides in the masterpage, no wonder
my code was getting confused about where to redirect to. I wonder if this is
by design. I am by no means any sort of asp.net expert, but it seems like a
big flaw in the use and implementation of masterpages. It almost seems like
the code should create a uniqueId for each page's (masterpage) form, so that
it can uniquely identify each page.

Thanks!
 
Back
Top