Saturday, March 24, 2012

Triggering modal popup with javascript causes popup controls to be disabled and popup disa

I'm triggering a modal popup to popup in a javascript:

document.getElementById('ModalPopupTrigger').click();

The element specified is set as the TargetControl for the modal popup.

The popup does popup but the control's on it can't be used and the popup disappears automatically after ~ 2 seconds...

Any clues as to what's going on here?

Define the BehaviorID property of your ModalPopupExtender control and use its show() method. For example (taken from the toolkit sample):

<ajaxToolkit:ModalPopupExtender runat="server" ID="programmaticModalPopup" BehaviorID="programmaticModalPopupBehavior" TargetControlID="hiddenTargetControlForModalPopup" PopupControlID="programmaticPopup"
BackgroundCssClass="modalBackground" DropShadow="True" PopupDragHandleControlID="programmaticPopupDragHandle" >

Given that declaration, you can show the popup by calling $find('programmaticModalPopupBehavior').show()


Ok, both methods actually work. The problem turned out to be that the javascript was triggered by a link button in an update panel which was causing the panel with the popup to refresh. Changed it to a label and it works fine...

No comments:

Post a Comment