Thursday, 8 May 2014

Ajax Control Toolkit : Popup Extender in Update Panel

I was working with Ajax Control toolkit controls. Came across a bug which was "Popup not closing after data loads.". Looked into the details of the bug found out particularity of scenario. The popup was shown using Popup Extender of Ajax control toolkit, Popup is inside the Update Panel.
On button click (which is in Popup) partial page load is happening. Once getting data from server, popup was supposed to get close, But was not behaving in expected manner.
I digged a little bit here and there to fond out that after ajax call Modal popup is not calling the hide method.
So we have to call the hide method on Modal Popup Extender.

I tried calling hide() method directly in script block but it was returning "null". The reason being i was trying to find the component before component initalization. So for calling hide method after component initialization i had to call it in Sys.Application.add_load.
 <act:ModalPopupExtender ID="mpe" runat="server" TargetControlID="LinkButton1" PopupControlID="Test" BehaviorID="mpeBehavior"

<script type="text/javascript">

    Sys.Application.add_load(function () {