Reputation: 773
the project is in MVC and i used this code in _Layout page and the control txtSearch is in layout page too
what below code doing is when i write something on text (txtSearch) and press enter that redirect to stockList page with entered parameter
$('#txtSearch').keypress(function(event) {
debugger;
var keycode = (event.keyCode ? event.keyCode : event.which);
if (keycode == '13') {
var strUrl = '/stocklist/All%20Categories-All%20Makers-All%20Models-0-0-' + $('#txtSearch').val();
location.href = strUrl;
}
});
what problem i got is in some page this action working very fine but while comes to stocklist page its not working properly will you please help me out from this.
Upvotes: 0
Views: 57
Reputation: 56
$('#txtSearch').keypress(function (event) {
debugger;
var keycode = (event.keyCode ? event.keyCode : event.which);
if (keycode == '13') {
var strUrl = '/stocklist/All%20Categories-All%20Makers-All%20Models-0-0-' + $('#txtSearch').val();
location.href = strUrl;
return false;
}
});
just add return false; in end of the code
Upvotes: 1