Arianule
Arianule

Reputation: 9063

Redirecting to an aspx.page using javascript

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

Answers (5)

Inácio Sumbane
Inácio Sumbane

Reputation: 1

In Asp.NET MVC

You can also do try this:

var parameter= $("#parameter_id").val();
  1. When you want to call another action from the curent controller:

    location.href = ("actionName?parameter=" + parameter);
    
  2. When you want to call a action from another controller:

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

Hope it helps.

Upvotes: 0

Lalit Kalka
Lalit Kalka

Reputation: 26

Please check

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

Upvotes: 1

Phong Vo
Phong Vo

Reputation: 1078

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

Upvotes: 2

Nipun Ambastha
Nipun Ambastha

Reputation: 2573

Try

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

Upvotes: 2

Raghubar
Raghubar

Reputation: 2788

Try This.

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

Upvotes: 1

Related Questions