Tag Archives: RegisterClientScriptBlock

Generate popup from Code behind

If we need to Generate Popup box from Code behind –

Page.RegisterStartupScript(“AlertWindow”, “<script language=javascript>alert(‘Please select atleast one Value.’)</script>”);

If the popup Page is using Ajax i.e. ScriptManager ,UpdatePanel Then

ScriptManager.RegisterClientScriptBlock(this.Page, GetType(), “AlertWindow”, “alert(‘Please select atleast one Value.’)”, true);

Close Popup window after some activity specially after db update

It’s very simple to close window after some activity ,Just put following code after which you want to close current window –

Page.RegisterStartupScript(“ClosePopup”, “<script language=javascript>window.close()</script>”);

Suppose If the popup page is using Ajax i.e. ScriptManager ,UpdatePanel then use following code –

ScriptManager.RegisterClientScriptBlock(this.Page, GetType(), “ClosePopup”, “window.close()”, true);