Monday, November 12, 2012

asp.net – How to prevent a page from posting back using javascript

I\’ve checked other code, and it looks like I just need to add return false to make it work. But, it\’s not working because it still posts back the page.



<asp:Button ID=\"_btnSearch\" Text=\"Search\" onclientclick=\"CheckForEmptySearchBox()\" />


<script type = \"text/javascript\">
function CheckForEmptySearchBox()
{
var boxContent = document.getElementById
(\"_ctl0_contentMain__lvTSEntry_ctrl0__txtClientName\").value;
if (boxContent == null || boxContent == \"\") {
alert(\"Please enter search criteria\");

return false;
}
}
</script>


Thanks for helping






Rating: 2 out of 5 based on 3 ratings



The post asp.net – How to prevent a page from posting back using javascript appeared first on Javascript ASK.






via Javascript ASK http://javascriptask.phpfogapp.com/asp-net-how-to-prevent-a-page-from-posting-back-using-javascript.html

No comments:

Post a Comment