ASP.NET - submit and close modal popup window

Asked By Anandh Ramanujam
10-Feb-12 09:27 AM
hi

Iam opening a modal popup window from an aspx page.

in modal popup, if i click server side button, perform some db changes and should close the window...

Here the code i have written:

in button_click event:

performing some db operations....
....
....
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Close", "javascript:window.close()", true);


But it doesnt work well. What happens is, when i click the button, it opens the same page in another new window, and prompt us 'are u want to close this window yes/no'. and the modal popup remains still.

Can u pls help me in this regard

thanks


  Suchit shah replied to Anandh Ramanujam
10-Feb-12 09:53 AM
Try it on this way
protected void btn_save(object sender, eventargs e)
 {              
// Here you can do your DB operation and now follow below way to close itt

   string scriptKey = "RefreshParentScript";
   string javaScript = "refreshParent();";
   ClientScript.RegisterStartupScript(this.GetType(), scriptKey, javaScript, true);
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Close", "javascript:window.close()", true); 


  }
  Anandh Ramanujam replied to Suchit shah
10-Feb-12 09:59 AM
where is this method refreshParent() defined ????
  dipa ahuja replied to Anandh Ramanujam
10-Feb-12 10:29 AM
try this

<a href="javascript:window.opener='x';window.close();">Close me</a>
    
 
  kalpana aparnathi replied to Anandh Ramanujam
10-Feb-12 01:10 PM
hi,

The ModalPopupExtender has the ‘Show()’ function to show the popup panel both at client side and the server side.
Each AjaxControlToolkit extender can has its own BehaviorID, we can use either the ID or the BehaviorID to find the AjaxExtender by writing “$find(‘ID’)” or “$find(‘BehaviorID’)” in javascript.
        [ExtenderControlProperty()]
       
[ClientPropertyName("id")]
       
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1706:ShortAcronymsShouldBeUppercase", Justification = "Following ASP.NET AJAX pattern")]
       
public string BehaviorID
       
{
           
get
           
{
               
string id = GetPropertyValue("BehaviorID", "");
               
return (string.IsNullOrEmpty(id) ? ClientID : id);
           
}
           
set
           
{
               
SetPropertyValue("BehaviorID", value);
           
}
       
}
  Anandh Ramanujam replied to Anandh Ramanujam
10-Feb-12 01:45 PM
I got the solution, by specifying <base target="_self"></base> attribute in <head> section. Now, its working fine.

Thanks for all ur support.
Create New Account
help
alot var Hi What are Master Pages in ASP.NET? or What is a Master Page? ASP.NET master pages allow you to create a consistent layout for the pages in your application. A single master page defines the look and feel and standard behavior that you want for all of the you want to display. When users request the content pages, they merge with the master page to produce output that combines the layout of the master page with the content from the content page. What are the 2 important parts of a master page? The following are the 2 important parts of a master page 1. The Master Page itself 2. One or more Content Pages Can Master Pages be nested? Yes, Master Pages
Page Directive? What is the purpose of page directive in aspx page? Directive Syntax Directives are instructions used to specify settings (related to how a page should render and processed) used by the page and user control compilers when they process ASP.NET Web Forms page (.aspx) and user control (.ascx) files. These are the essential part of every ASP.NET Page or Control. Directives can be located anywhere in an .aspx or .ascx file, but the values, same as any HTML tag) that are specific to that directive. Special Note: The @ Page directive can be used only in .aspx files, and the @ Control directive can be used
Remove(e.TabPage); } _cache.Add(e.TabPage); } } private void button1_Click(object sender, EventArgs e) { TabPage page = new TabPage("TabPage" + pageNumber.ToString()); AddControlsToTabPage(page); this.tabControl1.TabPages.Add(page); pageNumber++; this.tabControl1.SelectedTab = page; } private void AddControlsToTabPage(TabPage page) { page.Controls.Add(this.tab1CheckBox1); page.Controls.Add(this.tabCheckBox2 page.Controls.Add(this.tabCheckBox3); page.Controls.Add(this.tabCheckBox4); page.Controls.Add(this.tabCheckBox5); page
Utilities; using System.Text.RegularExpressions; using System.Net; public partial class Production_OA_Config : System.Web.UI.Page { #region Public Variables & Objects ExceptionHandler objHandlers; OAEntity _oaEntity = new OAEntity(); List<object> obj = new List PnlAutomated.ClientID + "').style.display = 'none';return false;"); / / * ** * / / ChkOA_Number_Availability.Attributes.Add("onclick", "if(!) return false; "); ScriptManager.RegisterStartupScript(this, this.GetType(), "", "Initial_Setting();showwarning();", true); / / ScriptManager.RegisterStartupScript(this, this.GetType(), "popup message", "setconformation();setScrollerWidth();slidStart();", true); if (CadPartListpopUp ! = null) { / / ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "cadpop", "document.getElementById('" + CadPartListpopUp.ClientID + "').style.display = '';ShowBackShadow('dvbackShadow', true);", true); } } catch ExceptionHandler ex) { ErrorHandler.SetMessage(ex.MessageDetails(), spnmessage); / / ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "popup message", "document.getElementById('" + ErrorPop.ClientID + "').style.display = '';", true); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "popup message", "Message_MoveTO_popup('" + spnmessage.ClientID + "', 'spnmessage');JqueryPopupShow();", true); } catch (Exception ex) { objHandlers new ExceptionHandler(ex, true); ErrorHandler.SetMessage(objHandlers.MessageDetails(), spnmessage); / / ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "popup message", "document.getElementById('" + ErrorPop.ClientID + "').style.display = '';", true); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "popup message", "Message_MoveTO_popup('" + spnmessage.ClientID + "', 'spnmessage');JqueryPopupShow();", true); } } private void BindActor() { / / ddlCustomer