Ulaş Kayalar

Ulaş Kayalar

  • 1.7k
  • 12
  • 536

Clicking the Button Without Refreshing the Page ASP.NET Webform

Dec 15 2023 2:31 PM

I want to search for the value we wrote in the textbox without refreshing the page. But when the button is clicked, the page is refreshed. The solutions below did not work. Can you help me?

<asp:TextBox ID="rulosParNoTx" runat="server" CssClass="rulos-tx" placeholder="Parti no ara" type="number" ClientIDMode="Static"/> 
              <asp:UpdatePanel runat="server">
                     <ContentTemplate>                               
             <asp:Button ID="rulosParNoBt" OnClick="rulosParNoBt_Click" runat="server" Text="" Style="display:none;"  ClientIDMode="Static"/>
                         </ContentTemplate>
                  <Triggers>
                      <asp:AsyncPostBackTrigger ControlID="rulosParNoBt" EventName="Click"/> 
                  </Triggers>
                   </asp:UpdatePanel>
             <script>
                 $(document).keyup(function (e) {
                     if ($('#<%=rulosParNoTx.ClientID%>').is(":focus")) {
                         $("#<%=rulosParNoBt.ClientID%>").click();                          
                     }
                     return false;
                  });
             </script>

Answers (3)