- Put a hidden
asp:buttonwithin theUpdatePanelor outside and set it as anAsyncPostBackTrigger. - Call the js function from
ItemDataBoundif needed, passing in theClientIDof the hiddenasp:button. - The js function will call the click event on the button passed in once the “OK” or whatever you set
buttonTxtto, button is clicked. - You can then handle the
UpdatePanel.Updateautomatically if the button is inside theUpdatePanelor callUpdatewithin thebutHidden_Click.
Markup:
<asp:UpdatePanel runat="server" ID="UpdatePanel1">
<asp:button id="btnHidden" style="display:none" runat="server" onclick="btnHidden_Click"/>
</asp:UpdatePanel>
Script:
function showjQueryUIDialogOkBtnCallback(buttonToClick, dialogSelector, buttonTxt, isModal, width, height)
{
var buttonOpts = {};
buttonOpts[buttonTxt] = function () {
$("#" + buttonToClick).trigger('click');
};
buttonOpts['Cancel'] = function () {
$(this).dialog("close");
$(this).dialog('destroy');
}
$(dialogSelector).dialog({
resizable: false,
height: height,
width: width,
modal: isModal,
open: function (type, data) {
$(this).parent().appendTo("form"); //won't postback unless within the form tag
},
buttons: buttonOpts
});
$(dialogSelector).dialog('open');
}
ASP.NET with jQuery popup dialog: how to post back on dialog closing