[英]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 我想使用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重定向到ASPP页面
function SearchContent() {
var txtBoxValue = $('#txtSearch').val();
if (txtBoxValue == "") {
alert("Please enter a value");
return false;
}
window.location("SearchResults?search="+txtBoxValue);
尝试
location.href = "SearchResults?search="+txtBoxValue);
请尝试window.location.href = "SearchResults?search="+txtBoxValue;
尝试这个。
location.replace("SearchResults?search="+txtBoxValue);
Please check 请检查
ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "alert('You are redirecting...');window.location='Yourpage.aspx';", true); ScriptManager.RegisterStartupScript(this,this.GetType(),“ popup”,“警报('您正在重定向...'); window.location ='Yourpage.aspx';”,true);
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);
Hope it helps. 希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.