使用 javascript 重定向到 aspx.page
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17874481/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Redirecting to an aspx.page using javascript
提问by Arianule
I want to redirect to an aspx page using javascript but upon attemptin this I get the following error
我想使用 javascript 重定向到 aspx 页面,但在尝试时出现以下错误
uncaught type error. Property 'location'of object[object global] is not a function
How cab I redirect to a aspx page using javascript
我如何使用 javascript 重定向到 aspx 页面
function SearchContent() {
var txtBoxValue = $('#txtSearch').val();
if (txtBoxValue == "") {
alert("Please enter a value");
return false;
}
window.location("SearchResults?search="+txtBoxValue);
回答by Nipun Ambastha
Try
尝试
location.href = "SearchResults?search="+txtBoxValue);
回答by Phong Vo
please try window.location.href = "SearchResults?search="+txtBoxValue;
请试试 window.location.href = "SearchResults?search="+txtBoxValue;
回答by Lalit Kalka
Please check
请检查
ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "alert('You are redirecting...');window.location='Yourpage.aspx';", true);
ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "alert('你正在重定向...');window.location='Yourpage.aspx';", true);
回答by Raghubar
Try This.
试试这个。
location.replace("SearchResults?search="+txtBoxValue);
回答by Inácio Sumbane
In Asp.NET MVC
在 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);
当你想从当前控制器调用另一个动作时:
location.href = ("actionName?parameter=" + parameter);
当你想从另一个控制器调用一个动作时:
location.windows= ("~/controllerName/actionName?parameter=" + parameter);
Hope it helps.
希望能帮助到你。