Here’s the button.
<asp:Button ID="_btnSearch" Text="Search" onclientclick="return CheckForEmptySearchBox(this.ClientID)" />
And here’s the Javascript function
<script type = "text/javascript">
function CheckForEmptySearchBox(id) {
alert("The ID of the button is: " + id)
return false;
}
</script>
I’m getting a alert box, saying “The ID of the button is: undefined“
Thanks for helping
It’s not ClientId, thats an server-side property use this.id.
ClientId is used to get the client-side id thats generated by ASP.Net and use it server-side.