It was just necessary to solve this recently. I have a general function to help solve this problem.
- Place the hidden
asp:button inside the UpdatePanel or outside and set it as AsyncPostBackTrigger . - If necessary, call the js function from
ItemDataBound by going to the ClientID hidden asp:button . - The js function will trigger an event of clicking on a button passed after pressing the "OK" button or any other button on which you set
buttonTxt , pressing the button. - You can then handle
UpdatePanel.Update automatically if the button is inside the UpdatePanel or calls Update inside butHidden_Click .
Markup:
<asp:UpdatePanel runat="server" ID="UpdatePanel1"> <ContentTemplate> <asp:button id="btnHidden" style="display:none" runat="server" onclick="btnHidden_Click"/> </ContentTemplate> </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");
source share