views:

6239

answers:

1

It seems that in some cases, if you end up with nested modalPopups wrapped with updatePanels (not ideal I know, and should probably be refactored, but that's what we're working with because of how some of the user controls we wanted to re-use were written), when you fire a postback that should open the nested modalPopup, instead it closes the parent one. For the sake of argument, if I set a breakpoint and run

((ModalPopupExtender)this.Parent.Parent.FindControl("modalPopupExtender'sID").Show();

right before the child modalPopup's Show() method is called, it works as we originally expected. It seems to me that, because when updatePanels are nested, they can post back their parent, the parent modalPopup "doesn't know" it's supposed to be showing and reloads its panel's visibility from scratch as false. Because the child modalPopup is then nested inside a parent panel whose visibility is false, calling Show() on it has no effect either. So instead of getting another modalPopup open, the current one closes. This is not an error, just behavior we didn't expect, so it was difficult to track down with no exception thrown anywhere, but I think the above explanation makes sense... If I've understood the problem incorrectly, please clarify it and enlighten me, because this doesn't seem to happen all the time I'd think it would!
At this point for this particular situation we're stuck re-writing some of those controls to not end up with nested updatePanels so this doesn't happen, but I'm curious:
Has anyone run into this problem before, and did you come up with any clever work-around that doesn't involve a call to FindControl() to re-Show() the modalPopup in question?

+3  A: 

I have solved this problem!
If you change the UpdatePanel's UpdateMode to "Conditional", the parent UpdatePanel doesn't post back when the child UpdatePanel posts back, and then nesting them is no issue at all!
I'm not sure why UpdateMode="Always" is the default, but, lesson learned.

Grank
We have learnt to always set our UpdatePanels' UpdateModes to Conditional...to be honest I am not entirely sure I can think of a scenario where we'd want them set to Always.
Richard Ev

related questions