How to disable a Parent window when the Child pop-up window opens in

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)







public void session()


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


string popupWindow = null;

string testScript = "'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 += "'" + 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 = "'Pdf/','new_Win');";ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", script, true);






protected void lbcasestudy1_Click(object sender, EventArgs e)


if (Session != null)


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




2/29/2008 12:48:14 PM 91979 articles. 3 followers. Follow

5 Replies

Similar Articles

[PageSpeed] 49

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

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/29/2008 1:45:55 PM

Have you tried using window.showModalDialog instead of ?

Peter Mourfield

Please remember to click “Mark as Answer” on the post that helps you.
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????

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????

3/1/2008 11:56:50 AM

Use the following tag in the <head> tag  

  <base target="_self" />

It will solve your problem . 

6/12/2008 6:56:23 AM

Similar Artilces:

how to disable the child window from getting opened, at the click of back button of the parent window
Hi, At the click of a button, a new window gets opened. But at the click of the back button of the parent window the child window again gets opened. I want to know how to disable the child window from getting opened at the click of back button? Plz help me.... thanks in advance.... Check these links. Otherwise, there is no way, NC...   hi, could you post ur code. actually how many ...

disable parent window when a child window opens
hello everyone  I have a page with iframes in it when i click a button on the page a small window should be opened and the parent page should be disabled unless I close the child window .I could disable all other controls on the page but couldn't disable the Iframes I tried using Modal popuextender, new window but nothing works so just please help me. thanks  Try this sample. Parent page: <form id="Form1" method="post" runat="server"> <input type="button" onclick="openWindow('Page2.aspx');" value=&...

disable parent window when child window is being open
I need to disable the parent window when clicked on a link that opens a pop up window. i want to enable the parent window if child window is clicked. the idea is same as in this forum. if you click "Select Tags" link. It dims the main window and opens the child window.   thanks.    you can use  window.showModalDialog for this.   Thanks.Thanks.Please mark the post as answer if it helps you!!! You can use onload and onunload events in your child window.    <html xmlns=""> <head&...

How to get the image from child window to parent window and thus close child window
Hi AllI have two pages reg.aspx and show.aspx. From reg.aspx, i call show.aspx to show images in a grid view, some of the content of grid view is shown below. Now, iam displaying images here using show.aspx. Now, when user clicks on any image under show.aspx, iam calling closewindow() function. My task is that when user clicks on this photograph, the corresponding photograph should be displayed in image box under reg.aspx. For this iam passing on imageid to closewindow function and assigning it to a session variable so that i can use it under reg.aspx to connect to DB and use it to disp...

how to open a pop up window by disabling the main window i.e pop up will remain in the main window until closing
 I need to make subpartitions of the contents of a form(transfring values from a page to a popup) and i need that when we click on a button on a page(main window) then a pop up will open by disabling the main window until n unless popup is closed.i.e focus will not lose from the popup until it is closed.RegardsSHOAIB RIZWAN see links below: google can be your friend :) Simply JS | june blog Or use this model on how to open ...

How to Close Child window from parent window If Child is opened..
Dear Friends, In My Application I want to close a child window(Popup)  at the time of page logout. I have written the code...It is working fine...but the problem is if i am closing the child window before login then it is opening the popup again and then closing it again. So can any body tell that how to detect from parent window if the child is opened or not. If it is opened then I will close else no action should taken for that. Thanks all....hope to see your help... My Code:     function ClosePopup(windowname)    {       ...

Datagrid: delete event getting fired on parent window when reloading parent from child window
Hi, I have a web form with a Add button and a datagrid with a delete column. On click of Add button I open a popup enter values on form and submit… on submit I reload the parent window. Now suppose I added a date 2/2/06 from popup, this date gets displayed in the datagrid. Now I delete this date using the Delete from the datagrid. Now I again click on add and try to add 2/2/06, what happens is the date gets added on submit but when the parent window reloads the date gets removed.  I have no idea how the delete is again getting fired on reload.  Thanks in advance. Dharmendra ...

Get Value from child window to parent window.....????
Hi all,in my page. on button click i m opening one child window(winchild.aspx) in winchild.aspx there is few values which is selected by user or enter some values by user.(like he checked few checkbox and enter some values into text problem is i wants that values wihich is selected or enter by user into child window,in my parent window(winparent.aspx). and store that values into textbox which is in parent window. after selecting value from child window. the child window will close .if i m store child window values into query string and after storing i write response...

Getting dataset from child window to parent window
Hi, I have two pages Parent.aspx and child.aspx.In parent page i have three GridView's also i have corresponding button near the each GridView. When i click Button1 near GridView1 it will popup a child aspx page.Child aspx page have a GridView having some records.i want to get the records from child GridView then have to populate the GridView1 in the parent window.Also i have to refresh only the GridView1 not the entire page to postback.How to handle this...please give suggestion....   Hi yvijay:            B...

Disable Parent window until child window is closed
Hi, A a child window which reload its opener under certain condition. for this i m using parent.opener.location.reload(). Is there any way I can close my child window that is open. As i see, after parent window reload it would have lost its reference to the child window... Cos when i say child.close() it says child as undefined.Is there anything we could do to close the child window before opening another one? The problem is: I get permission denied error when my parent location changes and my pop up window refers to the previous parent location. If closing is not possible then can...

How To get the values of Child Window to the Parent Window
I have a child Window Open by javascript Function On That i Have a Datagrid Now I want that  user can select the row by clicking (or DoubleClick) on it SO that the slected row value can get back to the Parent Window How this  can be done Plz Help Its Urgent Thanks a lotThanks & Regards HR Have you tried using Session["<your variable>"] ?Best,Doug...

Getting data from child window to parent window
Hi I have popped up an aspx window on click of a button event on a page. Here, iam selecting some values and getting all these values in to a text box. I have a Button on the child window. When i click on it. All the value present in that text box should come in to a text box on parent window. How do we do that?     Thanks! Santhosh return values from popup to the parent page(Child To Parent)Success Be YoursNJoy Programming...Blogging @ xploredotnet...

open a new pop-up window having a pop-up window already open....
Hi all, pls help I have done coding to open a pop window, its opening without any problem, now I want to open an new pop-up window keeping the older pop-up open, currently as I try to open page in the new pop-up, the page is displayed in the older pop up window instead of showingin a new pop-up window. Please help in this regard Thanks  Avaneesh Bajoria Hi,you popup window objects may be overwritten... post your code... VasanthakumarSoftware Engineer.  hi!use different titles for each window:        var i =0;    &nb...

open a new pop-up window having a pop-up window already open...
Hi All, Please help, I am opening a pop-up window using the following statement IN JAVASCRIPT: function openSLST() {"pgnew.aspx",null,"height=700,width=800,status=no,toolbar=no,menubar=no,location=no,left=5,top=5,scrollbars=yes"); }  the above function is called as below withiin a <tr></tr> tag : <a runat="server" id="aslst" class="avilink" onclick="openSLST();" href="#">AviList</a> a new window pops up so far so good.... now when i try to open a new pop-up(i want the p...

Web resources about - How to disable a Parent window when the Child pop-up window opens in -

How To Disable Facebook’s Tag Suggest
Facebook last week quietly reintroduced its tag suggest feature, which uses facial-recognition technology to assist users in tagging their friends ...

How do I disable the video autoplay? - Facebook-Hilfeforum - Facebook
Stop the video autoplay! Give an option to disable! STOP! STOP!

Whopper Sacrifice Forced to Disable Behavior by Facebook (Updated)
... waves for its creative (and aggressive) use of Facebook friend removals as a way to spread the application, Facebook has forced it to disable ...

Adblock Browser - By Adblock Plus. Block ads, browse more efficiently, remove popups, disable blacklist ...
... ratings, see screenshots, and learn more about Adblock Browser - By Adblock Plus. Block ads, browse more efficiently, remove popups, disable ...

Sitelinks Wont Disable - Flickr - Photo Sharing!
More at

How to Disable Facebook Places - YouTube
Learn how to disable places on Facebook altogether or just change your settings for better privacy. For more details, see http://lifehacker. ...

Java Warning - PC users told to disable Java - Security Flaw
Despite a fix, US authority continues to recommend users disable Java in their browsers.

US DOT: Auto makers should disable in-dash electronics when cars are moving
Automobile makers should prevent drivers from using their in-vehicle electronic devices to browse the Internet and send text messages while their ...

Java Hack - Experts Urge PC Users To Disable Java - Security Flaw
... update to address a critical flaw in its widely used Java program after the US Department of Homeland Security urged computer users to disable ...

Java Hack - Experts Urge PC Users To Disable Java - Security Flaw
A flaw in Java software is so dangerous that people should stop using it, security experts warn. JavaScript disabled. Please enable JavaScript ...

Resources last updated: 1/17/2016 6:09:37 AM