admin管理员组文章数量:1302274
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);
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);
Share
Improve this question
asked Jul 26, 2013 at 6:34
ArianuleArianule
9,06345 gold badges121 silver badges179 bronze badges
1
- window.location isn't a function. See developer.mozilla/en-US/docs/Web/API/window.location for references. – Alxandr Commented Jul 26, 2013 at 6:43
5 Answers
Reset to default 2Try
location.href = "SearchResults?search="+txtBoxValue);
please try window.location.href = "SearchResults?search="+txtBoxValue;
Try This.
location.replace("SearchResults?search="+txtBoxValue);
Please check
ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "alert('You are redirecting...');window.location='Yourpage.aspx';", true);
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.
本文标签: aspnetRedirecting to an aspxpage using javascriptStack Overflow
版权声明:本文标题:asp.net - Redirecting to an aspx.page using javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741706662a2393600.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论