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?
JavaScript
$(document).keyup(function (e) {
if ($('#').is(":focus")) {
$("#").click();
}
return false;
});
Satyaprakash SamantarayRank #101 · 21.1K reputationPosted Dec 16, 2023, 1:41 PM EST
For more details >> https://tinyurl.com/4zj22e5d
Jayraj ChhayaRank #304 · 8.2K reputationPosted Dec 18, 2023, 1:02 AM EST
Cause
The page is being refreshed because the button click event triggers a postback to the server, causing the entire page to reload.
Solution
To achieve the desired behavior of searching without refreshing the page, you can use AJAX and the UpdatePanel control in ASP.NET Webforms.
$(document).keyup(function (e) { if ($('#').is(":focus")) { $("#").click(); } return false; });With this setup, when the button is clicked, only the content inside the UpdatePanel will be refreshed, and the rest of the page will remain unchanged.
Ulaş Kayalar9 reputationPosted Dec 20, 2023, 8:14 AM EST