Redirecting to aspx.page using javascript

I want to redirect to an aspx page using javascript, but when I try this, I get the following error

uncaught type error. Property 'location'of object[object global] is not a function 

How to redirect a taxi to an aspx page using javascript

 function SearchContent() { var txtBoxValue = $('#txtSearch').val(); if (txtBoxValue == "") { alert("Please enter a value"); return false; } window.location("SearchResults?search="+txtBoxValue); 
0
source share
5 answers

Try

 location.href = "SearchResults?search="+txtBoxValue); 
+2
source

try window.location.href = "SearchResults?search="+txtBoxValue;

+2
source

Try it.

 location.replace("SearchResults?search="+txtBoxValue); 
+1
source

Please check

ScriptManager.RegisterStartupScript (this, this.GetType (), "popup", "alert ('You are redirecting ...'); window.location = 'Yourpage.aspx';", true);

+1
source

In Asp.NET MVC

You can also try:

 var parameter= $("#parameter_id").val(); 
  • If you want to call another action from the current controller:

     location.href = ("actionName?parameter=" + parameter); 
  • If you want to call an action from another controller:

     location.windows= ("~/controllerName/actionName?parameter=" + parameter); 

Hope this helps.

0
source

All Articles