Thursday, November 13, 2014


if Session is NULL then Close Popup and Redirect Parent window to some location
using JavaScript and Asp.net


VeerKMS='Project home folder name'

if (Session["UserId"]==null)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "opener.location.href ='/VeerKMS/Login.aspx';self.window.close();", true);
            return;
              
        }


Display Window Before Closing Current PopUp window

ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "setTimeout(function(){window.close();},500);", true);
            ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "alert('Data Saved Successfully.');", true);


Refresh parent window using invisible button from child window

<asp:Button  style="display:none" ID="invisibleButton" runat="server" OnClick="RemoveRecordFromGrid" />


 <script type="text/javascript" language="javascript">

       
        function WindowClose()
        {
       
        var form1=window.opener.document.getElementsByTagName("form")[0];
       
        //alert(form1.ctl00_ctl00_cphMaster_cphkycmaster_invisibleButton);
            form1.ctl00_ctl00_cphMaster_cphkycmaster_invisibleButton.click();
            window.close();
        }
      
    </script>

 protected void RemoveRecordFromGrid(object sender, EventArgs e)
    {
        Refresh_GrdViewAccountDetails();
    }

No comments:

Post a Comment