当前位置: 代码迷 >> JavaScript >> 在JavaScript按键内调用C#公共无效函数
  详细解决方案

在JavaScript按键内调用C#公共无效函数

热度:7   发布时间:2023-06-05 09:30:34.0

我已经搜索了很久了,如何在javascript按键内部调用我的public void search()。 asp.net中的Newb谢谢! 这是我的aspx代码。

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

     function checkKeypress(key) {
         var TestVar = document.getElementById('<%= Search_Employee.ClientID %>');
         '<% search(); %>';
     }
</script>
[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>
  相关解决方案