User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 423,950 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,165 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 5190 | Replies: 1
Reply
Join Date: Mar 2006
Posts: 18
Reputation: mikefitz is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
mikefitz mikefitz is offline Offline
Newbie Poster

Help Problem closing Browser with Window.Close

  #1  
Dec 21st, 2006
Hi,
I have an ASP.NET application that will not close a Browser using the Javascript Window.Close() command.

I am opening a Browser on top of the current Browser to display and collect additional information. In the Click event of the command button on the pop-up Browser, I execute some VB.NET code prior to calling the javascript Window.Close() command. This works fine for three workstations in the office, but two workstations will execute the VB.NET code, but will not close the Browser, even clicking the X in the browser window will not close the pop-up Browser on these two workstations. They just hang. The Internet Options appear to be identical on all the workstations in the office. All the workstations are using Internet Explorer 6.0. Does anyone have any ideas as to why the pop-up Browser will not close on these two workstations?

Thanks,
Mike
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2006
Posts: 1
Reputation: shatnawi is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
shatnawi shatnawi is offline Offline
Newbie Poster

Solution Re: Problem closing Browser with Window.Close

  #2  
Dec 21st, 2006
Hi man i will post this to help you in the situation

Here's the code for the parent page:
  1. [color=blue]public[/color] [color=blue]class[/color] Default : Page
  2. {
  3. [color=blue]protected[/color] TextBox txtFirstName;
  4. [color=blue]protected[/color] TextBox txtLastName;
  5. [color=blue]protected[/color] Label Label1;
  6. [color=blue]protected[/color] Label Label2;
  7. [color=blue]protected[/color] HyperLink HyperLink1;
  8.  
  9. [color=blue]private[/color] [color=blue]void[/color] Page_Load([color=blue]object[/color] sender, EventArgs e)
  10. {
  11. [color=green]//create our update function[/color]
  12. [color=blue]string[/color] scr = @"<script>
  13. function update(elemValue)
  14. {
  15. document.getElementById('txtFirstName').innerText=elemValue[0];
  16. document.getElementById('txtLastName').innerText=elemValue[1];
  17. }
  18. </script>";
  19. [color=green]// register the javascript into the Page[/color]
  20. Page.RegisterClientScriptBlock("update", scr);
  21. [color=green]//add our popup onclick attribute to the desired element on the page (Here, Hyperlink1)[/color]
  22. HyperLink1.Attributes.Add("onclick", "window.open('popup.aspx',null,'left=400, top=100, height=250, width= 250, status=n o, resizable= no, scrollbars= no, toolbar= no,location= no, menubar= no');");
  23.  
  24.  
  25. }
  26.  
  27.  

And, here's the code for the child "Popup" page:

  1. [color=blue]public[/color] [color=blue]class[/color] popup : System.Web.UI.Page
  2. {
  3. [color=blue]protected[/color] System.Web.UI.WebControls.TextBox TextBox1;
  4. [color=blue]protected[/color] System.Web.UI.WebControls.Label Label2;
  5. [color=blue]protected[/color] System.Web.UI.WebControls.TextBox txtLastName;
  6. [color=blue]protected[/color] System.Web.UI.WebControls.TextBox txtFirstName;
  7. [color=blue]protected[/color] System.Web.UI.WebControls.Label Label1;
  8.  
  9. [color=blue]private[/color] [color=blue]void[/color] Page_Load([color=blue]object[/color] sender, System.EventArgs e)
  10. {
  11. [color=blue]string[/color] scr= @"<script>
  12. function Done()
  13. {
  14. var fName=document.getElementById('txtFirstName').value;
  15. var lName=document.getElementById('txtLastName').value;
  16. var ret= new Array(fName,lName);
  17. window.opener.update(ret);
  18. window.close();
  19. }
  20. </script>;";
  21. Page.RegisterClientScriptBlock("done", scr);
  22. }
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 6:16 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC