I’m trying to call an blockUI after a buttonclick, but I can’t get it to work.
What am I doing wrong?
Script:
$(function() {
$('#<%= btnSave.ClientID %>').click(function(e) {
e.preventDefault();
$.blockUI({
message: '<div><h1><img src="Images/busy.gif" /> Please wait...</h1>',
css: { textAlign: 'center', border: '3px solid #aaa', padding: '10px, 0px, 0px, 0px' , verticalalign: 'middle' }
});
var btn = document.getElementById("ctl00_ContentPlaceHolder1_btnHidden");
btn.click();
});
});
Button:
<asp:Button ID="btnSave" runat="server" Text="Save" CssClass="button" Width="200" />
Since you’re in an UpdatePanel, use
.live()here, like this:.live()listens at thedocumentlevel for a click frombtnSaveto bubble up…so it works when the element is added, removed, replaced, etc. (and your UpdatePanel is replacing it each postback), where as.click()attaches directly to the element…and thatclickhandler is lost when the element is replaced.