Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect from asp.net page to another using javascript function

I know that if I want to redirect from asp.net page to anther in code behind I need to write-

Response.Redirect("SomePage.aspx");

My question is if is it possible to do the same thing in javascript function, and if it is so how?

thank you!

like image 890
user3475785 Avatar asked Apr 11 '14 13:04

user3475785


People also ask

Can JavaScript redirect?

JavaScript has the APIs that allow you to redirect to a new URL or page. However, JavaScript redirection runs entirely on the client side. Therefore it doesn't return the status code 301 (move permanently) like a server redirection.

What is response redirect in ASP NET?

Response. Redirect sends an HTTP request to the browser, then the browser sends that request to the web server, then the web server delivers a response to the web browser. For example, suppose you are on the web page "UserRegister. aspx" page and it has a button that redirects you to the "UserDetail.


2 Answers

This should do:

window.location = "SomePage.aspx";

or

window.location.href="SomePage.aspx";

or

window.location.assign("SomePage.aspx");
like image 121
Amit Joki Avatar answered Oct 11 '22 00:10

Amit Joki


Try this....

ScriptManager.RegisterStartupScript(this, this.GetType(), "onclick", "javascript:window.open( 'SomePage.aspx','_blank','height=600px,width=600px,scrollbars=1');", true);
like image 40
Jameem Avatar answered Oct 11 '22 01:10

Jameem