5

I have added an ASPxPopupControl, which includes a Save Button, and I want to close it after saving a record.

I tried the following:

 string str = @"<script language=""javascript"" type=""text/javascript"">function HideEscalateAsk() {pcEscalteAsk.Hide();}</script>";
                   Page.RegisterClientScriptBlock("ClientScript", str);

but it still doesn't work. How can I close the ASPxPopupControl?

bd33
  • 502
  • 1
  • 15
  • 30
ghanshyam.mirani
  • 3,075
  • 11
  • 45
  • 85
  • care to add correct tag.. if it is regarding devexpress control then add `devexpress` tag also.. try to put this client script code on page and then call client side click event of save button.. what ever method you are using.. – Niranjan Singh Jan 07 '12 at 16:56

2 Answers2

5

First thing. How are you handling Save Button; Server Side event or Client Side.

If you are using client side then use Callback server side event to save data and End Callback client event to close popup.

If using Server Side event then use ASPxPopupControl.ShowOnPageLoad Property.

protected void btnShowPopup_Click(object sender, EventArgs e) {
            txtPopup.Text = txtMain.Text;
            ASPxPopupControl1.ShowOnPageLoad = true;
        }
        protected void btnOK_Click(object sender, EventArgs e) {
            // TODO: your code is here to process the popup window's data at the server
            txtMain.Text = txtPopup.Text;
            ASPxPopupControl1.ShowOnPageLoad = false;
        }

Refer following links for information:
How to show the ASPxPopupControl
How to show and hide a popup window via server side code

Niranjan Singh
  • 18,017
  • 2
  • 42
  • 75
0

I think this is the best way for that as DevSupport mentioned. You must be write a java script like below:

//This function will close the pop window
function ClosePopWindow() {
     var paentWin = window.parent;
     window.parent.PopWindow.Hide();
}

And

//This function will clear inside content of pop window
function ClearPopWindow() {
        var paentWin = window.parent;
        paentWin.PopWindow.SetContentHtml(null);            
   }

and then call it from code behind when you need (after all of process you want to do) like this:

Page.ClientScript.RegisterStartupScript(GetType(), "script", "ClosePopWindow();", true);

or if you want to clear content you can use second function. Attention the PopWindow is ClientInstanceName of ASPxPopupControl. This approach will work in any situation for example when pop window defined in Master page and content URL is a window without master page because it try to get parent window in final html elements in browser.

You can read a Dev Support answer at this: https://www.devexpress.com/Support/Center/Question/Details/B199294

And from ASP.NET Forums, Terry Guo answer at this: http://forums.asp.net/t/1990775.aspx?How+to+close+the+popup+from+the+popup+containing+page+

Hope this help.

QMaster
  • 3,743
  • 3
  • 43
  • 56