Search code examples
javascriptasp.nethttp-redirectdotnetnukekeypress

Assign "Enter" key press to submit form in DotNetNuke


After extensive research on the internet I can't find a way to get my DNN module to virtually click the "Search" button and stay there, because after doing what I want somehow DNN hijacks my keypress and redirects to the Home page of the portal.

Even in the production environment it redirects to the local development environment. I don't have full knowledge of how the portal is configured because I "inherited" it, but I neither know where to search...

Any tips on this?

BTW, my code is the following and works correctly before DNN redirects :

  $("input").keypress(function (event) {
       if (event.which == 13) {
            event.preventDefault();
            $("#<%=lbtnBuscar.ClientID%>").click();
       }
  });

Solution

  • I managed to find the answer by myself. To protect the application to redirect it's necessary to use this line of code:

    //13 is the ASCII code of Enter key

    ClientAPI.RegisterKeyCapture(pnContainer, btnSearch, 13);

    The javascript I used is no longer necessary.