Postback UpatePanel on close of jQuery dialog

  • Put a hidden asp:button within the UpdatePanel or outside and set it as an AsyncPostBackTrigger.
  • Call the js function from ItemDataBound if needed, passing in the ClientID of the hidden asp:button.
  • The js function will call the click event on the button passed in once the “OK” or whatever you set buttonTxt to, button is clicked.
  • You can then handle the UpdatePanel.Update automatically if the button is inside the UpdatePanel or call Update within the butHidden_Click.

Markup:

[sourcecode language="xml"]
<asp:UpdatePanel runat="server" ID="UpdatePanel1">
<asp:button id="btnHidden" style="display:none" runat="server" onclick="btnHidden_Click"/>
</asp:UpdatePanel>
[/sourcecode]

Script:
[sourcecode language="javascript"]
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’);

}
[/sourcecode]

ASP.NET with jQuery popup dialog: how to post back on dialog closing

One Response to Postback UpatePanel on close of jQuery dialog

  1. Neat trick, however I have not been able to get it work. The click() is called for the hidden button (OnClientClick=”alert(‘test’);”) but the server side event handler is not.

    Chris

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>