0

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.

1 Answer 1

1
$('#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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.