Asked by:
ModalPopupExtender

Question
-
User706013099 posted
I have a curious problem with one or other of the ModalPopupExtender and the PopupControlExtender. This is (necessarily) quite a complex page where I use the ModalPopupExtender in code behind to populate and open a popup containing a GridView inside an UpdatePanel. Within the GridView RowCreated event handler I wire up a PopupControlExtender to the mouseover of an image within the row as follows:
Protected Sub WireUpSourcesPopup(ByVal s As Object, ByVal e As GridViewRowEventArgs) Handles Facts.RowCreated If e.Row.RowType = DataControlRowType.DataRow Then Dim fact As FactInfo = e.Row.DataItem If fact.FactType = 0 Then e.Row.Cells(2).Font.Bold = True Dim icon As Image = CType(e.Row.Cells(3).FindControl("btnSource"), Image) If fact.Sources Then Dim pce As PopupControlExtender = CType(e.Row.FindControl("pceSources"), PopupControlExtender) If Not pce Is Nothing Then Dim id As String = String.Concat("pce", e.Row.RowIndex) pce.BehaviorID = id Dim show As String = String.Format("$find('{0}').showPopup();", id) Dim hide As String = String.Format("$find('{0}').hidePopup();", id) Dim delayedhide As String = "setTimeout(""" + hide + """, 500)" icon.Attributes.Add("onmouseover", show) icon.Visible = True End If Else icon.Visible = False End If End If End Sub
[I did have some additional code to hide this 2nd popup but have currently removed this in the interests of simplicity - whether present or not I still get the error described below]By the way, I do know that there is a HoverMenuExtender but I could never get this to allow me to mouse into the popup for some reason, and the above approach works fine.
This small 2nd popup is populated with a series of links by means of a page ScriptMethod (using the DynamicServiceMethod and DynamicContextKey properties of the PopupControlExtender.
Anyway, all of this works when the links are simple links to a new page. The issue is when I populate the links as popups (using javascript:window.open...). In this case, clicking on a link causes the popup to open correctly but the parent page is completely empty apart from the text '[object]'.
I hope that this is an oversight on my part rather than a fundamental issue with the PopupControlExtender. Any thoughts or even suggestions as to how I might go about investigating this would be very welcome.
Jon
Thursday, April 26, 2012 10:58 AM
All replies
-
User842795017 posted
hi...
Refer this
http://forums.asp.net/t/1794569.aspx/1?AJAX+ModalPopupExtender
Friday, April 27, 2012 1:30 AM -
User1509044783 posted
Hello
It is likely that the onclick event handler of the link is overridden by the controls after you've got javascript:window.open. See if you can avoid putting javascript code in those links targeted. Or consider when click those links, pop up the ModaPopup by javascript and open a new window, http://www.geekzilla.co.uk/View38736C2B-BAD3-418A-A5B0-DAC4F1A5A83A.htm
Monday, April 30, 2012 4:01 AM -
User706013099 posted
Thank you for the suggestions. Unfortunately I haven't yet been able to get this to work. I have since come to the conclusion that the heart of the problem is that the PopupControlExtender (and presumably also the ModalPopupExtender) does not support 'nesting'.
As a result, I have since built a simpler test page using Wang Hai Feng's enhanced PopupControlExtender (see http://www.codeproject.com/Articles/184651/Modify-and-Use-PopupControlExtender-to-Create-Nest) and have generally managed to create 3 'levels' of nested popup (which I will call Popup 1, 2 and 3 here).
Popup 1 contains a GridView which is pre-populated server-side (on page load) and is opened from a link on the main page. Each row of the GridView contains a PCE and an Image which has its OnClick event wired up to do a showPopup of popup 2. Popup 2 is a list of links which is populated dynamically by a page method which builds the HTML. This all works well and I can get Popup 3 to display. The problem is that I want each of the links in popup 2 to open a popup 3 with specific data populated by another page method. Clearly I cannot in this case have a PCE for each link in popup 2, so what I have done so far is to have one PCE in popup 2 with a single TargetControlID (a simple link with href='#' - which could of course be hidden). If I simply click on this targetControlID then popup 3 displays, but this of course does not give me the required context key. So what I have done is to build each link in popup 2 with an onclick to a Javascript function (ShowPopup3) which takes a parameter to identify the link. The ShowPopup3 function finds the PCE behavior using the declared BehaviorID and sets its _dynamicContextKey as follows:
function ShowPopup3(id) { var pce = $find('pceSourceBehavior'); pce._DynamicContextKey = id;
It then just needs to show the popup. I have tried doing this 2 ways - either simply doing a pce.showPopup() or 'clicking' on the declared TargetControlID. In both cases, the page method is reached with the required context key. However, popup 3 is not shown and popups 1 and 2 are both hidden. It is as if I am getting a full postback, but a breakpoint in Page Load is not activated.
I have also tried changing the final popup to a ModalPopupExtender, but this causes worse problems (presumably because the Toolkit version of this also does not support nesting).
I do not know if this is related to the original issue where the parent page is empty, and I also do not know if this is an issue that is specific to my use of the modified PopupControlExtender (which maintains a stack of popup references). But if anyone has any ideas then that would be very much appreciated.
Jon
Monday, April 30, 2012 8:04 AM -
User706013099 posted
Well in the end in desperation I changed all my popups to use the standard ModalPopupExtender rather than the PopupControlExtender and it all works (I guess my accidental mistitling of this thread should have given me a clue!)! So it seems that the 2 extenders do not use the same code base after all and their behaviour is quite different with the MPE supporting nesting and the standard PCE not. Not really a big deal in my scenario, as I can handle an explicit close, but it is a pity that the MPE does not support positioning relative to the triggering control. Clearly the 2 authors did not communicate.
Jon
Tuesday, May 8, 2012 5:17 AM