I have the following BlockUI javascript set up to run on an aspx page which is in a ContentPlaceholder of a Master page. When the page loads and when I click the ASP button, the javascript fires, and shows the alert boxes 1 and 4, but not 2 and 3.
<script type="text/javascript">
$(document).ready(function() {
alert('alert1');
$('#Button3').click(function() {
alert('alert2 button clicked');
$.blockUI({ message: '<h1>Just a moment...</h1>' });
alert('alert 3 It clicked!');
});
alert('alert4!');
});
</script>
I am think it has something to do with finding the button inside of the ContentPlaceholder.
Any Ideas anyone?
Here’s the button, no code behind events are set up on it.
<td class="style17">
<asp:Button ID="Button3" runat="server" Text="Button" />
</td>
Change selector from
$('#Button3')to$('#<%= Button3.ClientID %>')By the way, if you want to prevent postback on this button click you must add
OnClientClick="return false;"to this button