Getting the ModalPopupExtender to work in SharePoint 2007

Getting the ModalPopupExtender from the Ajax Control Toolkit to work (decently) in SharePoint was not exactly a walk in the park. With a default SharePoint installation, the modal popup is partly positioned 'outside' of the page (you only see the bottom right part of the popup in the top left corner of the browser). Postbacks are not executed or executed poorly and the page gets garbled up. A possible solution for the positioning of the popup is to set the X and Y property of the ModalPopupExtender. Downside is you never know (for sure) if the popup is positioned inside the visible part of the browser because of things like non-maximized browser, different resolutions and so on.
Today we seem to have solved our issues with the ModalPopupExtender in SharePoint. We haven’t tested it in all scenario’s yet, but we’ll get to that. At this point everything looks the way it is supposed to. And it seems to work, too… ;).

The extra steps we took to make these two play together the way we wanted them to, besides the usual steps to make Ajax work in ASP.NET 2.0, are:

* Because of our setup with close-images that postback (because we have to clear controls and that sort of stuff) and more, we couldn’t use the TargetControlID property for the ModalPopupExtender. Well, we could, but that would result in the background not being displayed properly half the time ;). This can be solved by setting the TargetControlID to a dummy control (like a hidden one) and showing the popup from code.

** We have a usercontrol with several usercontrols in it. This one usercontrol (the parent) was added to a page. The normal (postback) controls on the usercontrols didn’t work after one of the modal popups was shown. And I can image neither would any other 'normal' controls on the page, but we didn't encounter this scenario. The problem was the page would freeze with a message in the taskbar stating ‘The page is busy submitting data to the server’ directly after an Ajax postback. The controls that performed a 'normal' postback did nothing: the serverside code just was not executed. We solved this by putting an updatepanel around everything inside the usercontrol. That way the normal controls would postback in an ajaxy way too, apparently solving the 'The page is busy' message.

We'll be testing this solution over the next few days. If any problems pop up, I'll keep you posted.

Published Fri, Mar 14 2008 6:59 AM by Rick van den Bosch

Comments

# re: Getting the ModalPopupExtender to work in SharePoint 2007

How did you account for the style changes when adding the DOCTYPE?

Monday, June 09, 2008 3:46 PM by pmcgouirk

# re: Getting the ModalPopupExtender to work in SharePoint 2007

@pmcgouirk:

The page we changed this for was not (negatively) affected by the change.

I know the style might change if you do this for other pages, and I'm not sure how to fix those. This might be because I haven't encoutered that (yet). ;)

Good luck.

Thursday, June 12, 2008 11:50 AM by Rick van den Bosch

# re: Getting the ModalPopupExtender to work in SharePoint 2007

Try using the publishing site portal,it doen not see any style changes plus it already has a doctype HTML transitional so u dont need to worry of adding XMLNS

also make sure you include panelfixups() just before adding the user control in createChildControls().

and do not keep modal popup inside the update panel

Thursday, August 21, 2008 10:20 PM by madhur

# re: Getting the ModalPopupExtender to work in SharePoint 2007

I tried the above steps, but still i am getting problem.I am able to view the modal popup in the site, but it appears in the left topmost cornet of site. Please help me to solve the issue

Thursday, December 18, 2008 9:38 AM by Kathir

# re: Getting the ModalPopupExtender to work in SharePoint 2007

Rather than changing the doctype, I just specify the .X and .Y poperties for the popup.  I'll do this in code behind if I have to (if they need to change).  Also, to get the modal background working in IE, I included this in my CSS:

.modalBackground {

  background-color:Gray;

  opacity:0.7;

  filter:alpha(opacity=70);

  position: absolute !important;

}

the "position: absolute !important;" fixes the modal background in IE.  

Tuesday, March 09, 2010 4:47 PM by David Jackson

# re: Getting the ModalPopupExtender to work in SharePoint 2007

It would be really really helpful if you posted at least some of your code on this article :)

You seem to be the only one on the web to have managed to do this and I am very much interested cause I am on the verge of burning the entire SharePoint farm!!!

Friday, October 22, 2010 12:32 PM by Etienne

Leave a Comment

(required) 
(required) 
(optional)
(required) 
Please add 7 and 7 and type the answer here: