views:

144

answers:

0

I am trying to hide modal popup from code behind. But it is not working.

<script type="text/javascript">
    //  a reference to the popup behavior
    var _popup;

    function LoadPopup() {
        //  find the popup behavior
        this._popup = $find('mdlPopup');
        // show the popup
        this._popup.show();

        // synchronously run the server side validation ...
        document.getElementById('btnDownload').click();
       //callback();         
    }

 <asp:Button ID="btnDownload" runat="server" Text="Download" CssClass="AlixButton"
     OnClientClick="LoadPopup();" Visible="false" Height="28px" />

<AjaxControlToolkit:ModalPopupExtender ID="mdlPopup" runat="server" TargetControlID="pnlPopup" PopupControlID="pnlPopup" ackgroundCssClass="modalBackground" />


<asp:Panel ID="pnlPopup" runat="server" CssClass="updateProgress" Style="display: none">
     <div align="center" style="margin-top: 13px;">
           <img src="Images/ajax-loader.gif" alt="" />
                  <span class="updateProgressMessage">downloading ...</span>
     </div>
</asp:Panel>

Code Behind:

 Protected Sub btnDownload_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnDownload.Click
    Try
        Dim mSurvey As New Survey
        Dim mUser As New User
        Dim dtExcel As DataTable
        mUser = CType(Session("user"), User)
        dtExcel = mSurvey.CreateExcelWorkbook(mUser.UserID, mUser.Client.ID)
        Dim filename As String = "Download.xls"
        Response.ContentType = "application/vnd.ms-excel"
        Response.AddHeader("Content-Disposition", String.Format("attachment;filename={0}", filename))
        Response.Clear()
        InitializeWorkbook()
        GenerateData(dtExcel)
        mdlPopup.Hide() ' Not Working here
        Response.BinaryWrite(WriteToStream.GetBuffer)
        Response.End()
    Catch ex As Exception

    Finally
        mdlPopup.Hide()
    End Try


    'GenerateExcel()

End Sub