Solved

Close ASP.NET web page using C#

Posted on 2004-08-12
10
2,514 Views
Last Modified: 2012-05-05
Hey,

   Does anybody know how to close ASP.NET .aspx web page using C# code.

   I have a .aspx popup that I want to close after finishing work. Something like window.close() in javascript. Does c# have anything like this?

  Thanks.
0
Comment
Question by:payal1711
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 11790237
Hi payal,
how are you... been a long time , haan ??...  
Well,  closing a window is a Client-Side operation.... so you can't do it from server side code. Have to use client side code (use javascript)...
You see, closing or starting any application in client computer is not possible from server side code (otherwise creating VIRUS would be far easier). Usually people go for javascript for these kind of client side operations.

I would rather use, say , a Button...  and in page_Load...
        Button1.Attributes.Add("OnClick", "javascript:self.close()")

-Baan
0
 
LVL 1

Author Comment

by:payal1711
ID: 11794761
Hey Baan,

   How are ya? yeah, long time since the last email.

   yes i came to know that yesterday when I was looking on the net after posting this question here. I got the code with Response.write and wrtie the javascript code as part of its argument. but that closes the window before my job is done. so there is a problem there and it doesnt launch the animated gif image that shows processing.

   Baan, I was wondering how to expedia and orbitz and other online reservation sites do this. You must have seen that when we select the options and hit search another page open up which shows processing and when it has results the window closes itself. I wanted to do something like that.

   ~Payal
0
 
LVL 1

Author Comment

by:payal1711
ID: 11796247

  Does anyone know javascript on how to open new pop ups every time a button is clicked? I dont want the page to be launched on the same pop up window everytime.

   I am opening the pop up window on button click event.

  Thanks,
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 11796520
ok.. add attribute to the button in the Page_Load...

Button1.Attributes.Add("OnClick", "javascript:window.open('PopUpWindow.aspx','MyPopUp','width=440,height=480,left=270,top=100')")
-Baan
0
 
LVL 18

Accepted Solution

by:
DotNetLover_Baan earned 50 total points
ID: 11796686
0
 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 11796701
0
 
LVL 1

Author Comment

by:payal1711
ID: 11798259
hey,

   Thank you for sending all those links. Now I know the problem in my code and have solved it partially.

        The problem is because the server is processing and I have put the thread to sleep, the animated gif doesnt show up on the page. It simply hangs. And if I refresh that page, then my whole program functionality is messed up there after.

        What option do I have?

      Payal
0
 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 11798443
I am not sure about that... 'cause I never done that. Well, few days back there were couple of discussion,here in EE, that had the same thing you want to do. I will try to find those PAQs and I will send you the links... that might help.
-Baan
0
 
LVL 1

Author Comment

by:payal1711
ID: 11812146
Thank you Baan,

    I will wait for the links.

  Payal
0
 
LVL 1

Author Comment

by:payal1711
ID: 11824510

 Well, it seems that we are not continuing with this idea as popup blocker blocks the window and the work is not done therefore. Thanks for the help Baan.

    Payal

 
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

738 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