Solved

c# - Close Internet Explorer window

Posted on 2006-10-23
5
2,840 Views
Last Modified: 2012-05-05
Hi.  I'm looking for a line of C# code that would automatically close my .aspx page.
Thanks.
0
Comment
Question by:cberinger
  • 2
  • 2
5 Comments
 
LVL 7

Expert Comment

by:yotamsher
ID: 17791775
in your .aspx code?
0
 
LVL 19

Accepted Solution

by:
Albert Van Halen earned 500 total points
ID: 17794263
ClientScript.RegisterStartupScript(this.GetType(), "CloseScript", "self.close();", true);

The last argument makes sure that this script code gets surrounded with script tags, so it depend where you put this line in your code...
0
 

Author Comment

by:cberinger
ID: 17795335
Looks good, but the IE window is awaiting a response from the client to close the window.  The problem is that this needs to be unattended.  

All of my code is located in my c# file.  There’s nothing in the .aspx file.  The only reason I run it as an .aspx page is because that’s all I’ve ever done.  Is there a quick way to attach my code to an .exe that will run & close?
0
 
LVL 19

Expert Comment

by:Albert Van Halen
ID: 17795932
Well, you cannot attach your 'server-side' code to a 'client-side' executable and run something.
Thank god for that !!

It's default behavior of IE. You can not change that.

See also this post
http://www.experts-exchange.com/Web/Web_Languages/Q_21981035.html
0
 
LVL 7

Expert Comment

by:yotamsher
ID: 17797314
What is it doing?
If it is not supposed to communicate with the server, but just run something, then offcourse you can wrap it as an exe, but then, how will it get to the client machine?
You need to be specific

Yotam
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This is an explanation of a simple data model to help parse a JSON feed
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now