32

Closed

ModalPopupExtender doesn't work with UpdatePanel

description

If an UpdatePanel is placed on a ModalPopupExtender, and a control on the UpdatePanel does a postback, then an error "Microsoft JScript runtime error: Sys.InvalidOperationException: Handler was not added through the Sys.UI.DomEvent.addHandler method." is thrown when trying to hide the ModalPopupExtender either in code or by clicking the OK or Cancel control. The same error occurred if I tried to put the ModalPopupExtender on the UpdatePanel instead.

These controls worked together in .Net 2.0, but I've been unable to get them to work after upgrading to .Net 3.5 and the latest ajax release, so I've come to believe that this may be a bug. I've posted code to reproduce the error here, but no solution has been posted: http://forums.asp.net/p/1464088/3374246.aspx#3374246

Edit: Sorry, I tried to be as thorough as possible to make sure it wasn't my error before posting this, but it turns out it is my error. I posted the solution in the forum referenced above. There's also more details at http://www.microsoft.com/communities/newsgroups/list/en-us/default.aspx?dg=microsoft.public.dotnet.framework.aspnet.webcontrols&mid=91257d4c-3207-437e-8405-c3897a76c0df.
Closed May 18, 2010 at 8:06 PM by BorisMo
This issue is fixed in 40412

comments

Maryan wrote Oct 2, 2009 at 10:01 AM

We have the same problems, including the last release 30930. Only release 30512 works fine.

We have tried to replace the ModalPopupExtender control from the old release in the source code, but it doesn't help. Looks like the problem is more global.

In the current release (30930) - the OkControlId and CancelControlId doesn't work or cause full post back to the server, the content of modal dialog is damaged (content is aligned by center etc), and each textbox in the modal dialog has redundant "," symbols (few commas are added after each dialog showing). Very bad guys, it was a good and perspective library some time ago...

GarethR wrote Oct 5, 2009 at 2:53 PM

I also have a number of issues with the ModalPopupExtender and UpdatePanels in the 30930 release. In my case I'm have an UpdatePanel which contains a ListView and within the InsertItemTemplate I have a ModalPopupExtender. This worked well in the previous 30512 release of the toolkit but in this release I get Sys.InvalidOperationException: A control is already associated with the element errors for controls within the ModalPopupExtender. Either removing the UpdatePanel wrapping the ListView (alternatively disabling PartialRendering) or removing the ModalPopup seems to be the only fix with this 30930 release.

Chyron wrote Oct 5, 2009 at 9:15 PM

I opened an issue for what is apparently a related issue. Same basic scenario - an UpdatePanel on a Modal Popup, but with a different bug. The specific problem being that Ajax isn't recognizing the Update Panel as if it isn't there at all.

http://ajaxcontroltoolkit.codeplex.com/WorkItem/View.aspx?WorkItemId=24801

JonathanHayward wrote Oct 6, 2009 at 4:33 PM

I have just upgrade from 30512 to 30930. I am to having problems with the ModalPopupExtender on a page inside an UpdatePanel. The page is throwing JavaScript errors for duplicate IDs and the "Modal Window" is displaying on its own accord on postback.

pickedaname wrote Oct 12, 2009 at 2:26 PM

Same problem I was hoping this new release fixed problems preventing production release but now I have new ones....modal in update panel causing full postbacks, the comma values being appended due to 'duplicate IDs (when there are none in the aspx file nor am I adding any controls in code)...no matter which release I go with old or new I am going to have issues....I will never ever ever ever use this toolkit in another project ever. Cannot afford the time consumption nor can I wit 30 days at a time for a solution to be published. I appreciate the hard work but surely you can understand why I cannot.

pickedaname wrote Oct 12, 2009 at 2:27 PM

Same problem I was hoping this new release fixed problems preventing production release but now I have new ones....modal in update panel causing full postbacks, the comma values being appended due to 'duplicate IDs (when there are none in the aspx file nor am I adding any controls in code)...no matter which release I go with old or new I am going to have issues....I will never ever ever ever use this toolkit in another project ever. Cannot afford the time consumption nor can I wit 30 days at a time for a solution to be published. I appreciate the hard work but surely you can understand why I cannot.

arunkym007 wrote Oct 13, 2009 at 9:21 AM

We have the same problem. When modal popup with in update panel then it gives a javascript error( When an event occured). Modal Popup with in updatepanel works fine in previous vesrsions.

tiferrei wrote Mar 4, 2010 at 6:15 PM

This is disgusting... it seems that the comma added to the input fields when the error occurs is still happening.
I think I will start migrating all the interface to jquery ajax, ...

AjaxFan wrote Mar 23, 2010 at 10:28 AM

Although the problem I experienced is directly related to description given above, I felt that it may help others who have experienced problems with a modalpopupextender inside an updatepanel.

Previously I was using the AjaxControlToolkit for ASP.NET 2.0 (dll 1.0.20229.0). One particular page has an updatepanel spanning the entire page (up_enitrepage). Within this updatepanel a modalpopupextender (mpe) shows a panel containing search functionality displayed within a gridview. In order to display this gridview (due to a partial postback) the controls within the popup panel are within another updatepanel. For example:


controls that get updated via the popup
      controls for search (textboxes, submit button, gridview, etc)



A selected gridview event was updating the page under the popup panel and closing the extender (i.e. up_enitrepage.Update() and mpe.Hide()) This was all working fine. However, after upgrading the AJAX library to 3.5 (dll 3.0.30930.0) all sorts of problems were occurring.

After hiding the popup the panel would still show on the page. Re-displaying the popup worked, but the targeted popup panel (shown the first time) was was still showing underneath.
Also, each textbox contained commas; more each time when showing the popup panel.

My solution was to move all the controls used for the modalpopupextender outside the updatepanel used for the entire page. So:


controls that get updated via the popup
  controls for search (textboxes, submit button, gridview, etc)


Originally I was never including a modalpopupextender inside an updatepanel, but since it was working for 2.0 I left it as is. However, after coming across all these problems, this post pointed me in the right direction. http://forums.asp.net/t/1464088.aspx

AjaxFan wrote Mar 23, 2010 at 10:30 AM

In my previous post I meant to say that what I was experiencing was NOT directly related to this post, but I feel that it may help others who are experiencing problems with modalpopextenders inside updatepanels.

Manifold1977 wrote May 8, 2010 at 4:43 PM

I solved all these issues by reverting the the 30930 versions of ModalPopupBehavior.debug.js, ModalPopupBehavior.js, FloatingBehavior.debug.js and FloatingBehavior.js to the 30512 versions and then recompiling the 30930 solution.

I hope this helps someone.