Link to home
Start Free TrialLog in
Avatar of payal1711
payal1711

asked on

Close ASP.NET web page using C#

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.
Avatar of DotNetLover_Baan
DotNetLover_Baan

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
Avatar of payal1711

ASKER

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

  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,
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
ASKER CERTIFIED SOLUTION
Avatar of DotNetLover_Baan
DotNetLover_Baan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
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
Thank you Baan,

    I will wait for the links.

  Payal

 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