How to disable a Parent window when the Child pop-up window opens in C#.net

My Code:

using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page

{

dbUtils dbu = new dbUtils();

//SqlDataAdapter dataAdapter;

//DataSet dSet;

//SqlCommand cmd;

//int value;

//string Temp,var;

protected void Page_Load(object sender, EventArgs e)

{

if (Page.IsPostBack == false)

{

session();

}

 

 

}

public void session()

{

if (Session["sess"] == null)

{

string popupWindow = null;

string testScript = "window.open('Default2.aspx','win','width=500,height=200,scrollbars= yes')";

string scriptID = "popup";

string myScript = buildScript(scriptID, testScript);

if (!Page.IsStartupScriptRegistered(scriptID))

{

Page.RegisterStartupScript(scriptID, myScript);

}

}

}

string buildScript(string id, string output_page)

{

string myScript = "\n";

myScript += "<script language='javascript' id='" + id + "'>\n";

//myScript += "window.open('" + output_page + "');\n";

myScript += output_page + ";\n";

myScript += "</" + "script>\n";

return myScript;

}

 

protected void lbcasestudy_Click(object sender, EventArgs e)

{

 

if (Session != null)

{

string script = "window.open('Pdf/','new_Win');";ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", script, true);

}

 

}

 

 

protected void lbcasestudy1_Click(object sender, EventArgs e)

{

if (Session != null)

{

string script = "window.open('Pdf/','new_Win');";ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", script, true);

}

}

}

-3
pvpradeepraghav
2/29/2008 12:48:14 PM
asp.net.getting-started 91979 articles. 4 followers. Follow

5 Replies
2446 Views

Similar Articles

[PageSpeed] 20

The easiest way to do that is by using the Ajax Control Toolkit Modal Popup, take a look if that is what you need:

http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ModalPopup/ModalPopup.aspx

But I've done it with plain javascript as well, and is not that hard...

Basically you just need to put a layer (div) with some transparency over the window and it will disable every thing under it

 


L. Skynyrd


Please, mark as answer when appropriate
-2
skynyrd
2/29/2008 1:45:55 PM

Have you tried using window.showModalDialog instead of window.open ?


Sincerely,
Peter Mourfield
www.mourfield.com

Please remember to click “Mark as Answer” on the post that helps you.
0
pmourfield
2/29/2008 1:51:08 PM

Thank you very much.It is very useful for me  but when the pop-up block opens and click the submit button another page should open in the same window...can u give me the suggestion????

0
pvpradeepraghav
3/1/2008 11:55:36 AM

Thank you very much.It is very useful for me  but when the pop-up block opens and click the submit button another page should open in the same window...can u give me the suggestion????

0
pvpradeepraghav
3/1/2008 11:56:50 AM

Use the following tag in the <head> tag  

  <base target="_self" />

It will solve your problem . 

-2
jaiprakashsingh1981
6/12/2008 6:56:23 AM
Reply: