Download as rtf, pdf, or txt
Download as rtf, pdf, or txt
You are on page 1of 1

In you aspx file include jquery in head section :

<head runat="server"> <title></title> <script src="js/jquery.min.js"></script> </head>

Place textbox and button in the page :


Search Customer with JQuery : <asp:Panel ID="panSearch" runat="server"> <asp:TextBox ID="tbxSearch" runat="server" AutoCompleteType="Disabled" AutoComplete="Off"></asp:TextBox> <asp:Button ID="btnSearch" runat="server" OnClick="btnSearch_Click" /> </asp:Panel> <div id="trsearchResult"> <div id="searchResult" height="300px" width="300px"> </div> </div> Text="Search"

Write below script just before the end of <body> tag. Replace the localhost URL with your URL :
<script type="text/javascript"> $("#trsearchResult").hide(); $("#searchButton").click(function () { if ($("#search").val() != "") window.location = "http://localhost:50154/Search-Result.aspx?search=" + escape($ ("#search").val()); }); $("#<%=tbxSearch.ClientID%>").keyup(function () { if ($("#<%=tbxSearch.ClientID%>").val().length > 0) { $.ajax({ type: "GET", url: 'http://localhost:50154/Search-Result.aspx', data: 'search=' + $("#<%=tbxSearch.ClientID%>").val(), success: function (data) { if ($("#<%=tbxSearch.ClientID%>").val() != "") { $("#trsearchResult").show(); $("#searchResult").html(data); } else { $("#trsearchResult").hide(); } } }); } else { $("#trsearchResult").hide(); } }); </script>

You might also like