0

I've been searching for a longtime, How can I call my public void search() inside my javascript keypress. Newb in asp.net Thanks! This is my aspx code.

<script language="javascript" type="text/javascript">
     window.addEventListener("keyup", checkKeypress, false);

     function checkKeypress(key) {
         var TestVar = document.getElementById('<%= Search_Employee.ClientID %>');
         '<% search(); %>';
     }
</script>
Timato1
  • 49
  • 7

1 Answers1

0
[System.Web.Services.WebMethod]
    public static void GetData()
    {
        MessageBox.Show("Calling From Client Side");
        //Your Logic comes here
    }

<asp:ScriptManager ID="ScriptManager2" runat="server" EnablePageMethods="true"/>
<body>
    <form id="form1" runat="server">
    <script type="text/javascript">
        function CallingServerSideFunction() {
            PageMethods.GetData();
        }
    </script>
    </form>
</body>
enginne
  • 11
  • 4
  • What is PageMethods in the last line? My void function name is search() I tried PageMethods.search() and it's not working. :( – Timato1 Feb 21 '19 at 09:40