Reputation: 9063
I want to redirect to an aspx page using javascript but upon attemptin this I get the following error
uncaught type error. Property 'location'of object[object global] is not a function
How cab I redirect to a aspx page using javascript
function SearchContent() {
var txtBoxValue = $('#txtSearch').val();
if (txtBoxValue == "") {
alert("Please enter a value");
return false;
}
window.location("SearchResults?search="+txtBoxValue);
Upvotes: 0
Views: 14515
Reputation: 1
In Asp.NET MVC
You can also do try this:
var parameter= $("#parameter_id").val();
When you want to call another action from the curent controller:
location.href = ("actionName?parameter=" + parameter);
When you want to call a action from another controller:
location.windows= ("~/controllerName/actionName?parameter=" + parameter);
Hope it helps.
Upvotes: 0
Reputation: 26
Please check
ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "alert('You are redirecting...');window.location='Yourpage.aspx';", true);
Upvotes: 1
Reputation: 1078
please try window.location.href = "SearchResults?search="+txtBoxValue;
Upvotes: 2