Niar
Niar

Reputation: 540

How to close current Browser window and redirect to a previously opened window for the same browser

i have two asp page,first one is home and second one is test. In home page user can select the type of test they want to take up, and after pressing start button a new window is open for taking the test. What i want to achieve is , after completing the test i want to close the test window and redirect to another page, and this redirect should hit the previously opened home window.

Upvotes: 1

Views: 10883

Answers (3)

Just code
Just code

Reputation: 13801

You don't clarify that you have popup window or blank window i am aspecting for the popup In submit click button press

String x = "<script type='text/javascript'>window.opener.location.href='**Your new url of new page after completing test**';self.close();</script>";
ScriptManager.RegisterClientScriptBlock(this.Page,this.Page.GetType(), "script", x,false);

From self close you will be able to close current window and by window.opener.location.href you will able to redirect to new url I hope this will help you

regards....:)

Upvotes: 4

user240141
user240141

Reputation:

Yes you can do these 2 ways:

  1. Window.Open() /.showmodalDialog() and keep parent and child open as well, or

  2. On the home page click on your start button. Use code Response.Redirect("~/Test.aspx"); assuming it resides with Home.aspx. Take your test using ASp.Net wizard control or hiddens divs what ever suits you easy. Manipulate data on test page , save and get result to and from database using SqlConnection and SqlCommand assuming you have Sql Server as backend. Hold the table or any value in either cache or Session and throw it on your home page. Do whatever you want.

Upvotes: 1

windowshostingasp.net
windowshostingasp.net

Reputation: 144

This will be not possible. What you can do is to redirect the user to the home page after completing the test, but this will be in the same windows.

Upvotes: -2

Related Questions