Jquery Ui Dialog With ASP.NET Button Postback

Do a postback in jQuery UI dialog

instead of __doPostBack('btnConfirm','');

 Yes: function () {
$("[id*=btnConfirm]").click();
},

UPDATING MY ANSWER

Take another button, with display none property and trigger that
Button

css

.hidden
{
display:none;
}

aspx

<asp:Button id="btnhidden" runat="server" onclick="btnhidden();" cssClass=hidden/>

javascript

  Yes: function () {
$("[id*=btnhidden]").click();
},

jQuery UI Dialog with ASP.NET button postback

You are close to the solution, just getting the wrong object. It should be like this:

jQuery(function() {
var dlg = jQuery("#dialog").dialog({
draggable: true,
resizable: true,
show: 'Transfer',
hide: 'Transfer',
width: 320,
autoOpen: false,
minHeight: 10,
minwidth: 10
});
dlg.parent().appendTo(jQuery("form:first"));
});

Postback in jQuery UI dialog

First of all you should have a correct CommandName and CommandArgument set on your ImageButton. Then call dialog from the OnClientClick. As I understood you have only one dialog element hidden somewhere so there should be no problems with ids:

<asp:ImageButton runat="server"
CommandName="Delete"
CommandArgument='<%# Eval("YourKeyFieldNameHere") %>'
OnCommand="ImageButton_Command"
OnClientClick="javascript:return showConfirmDialog(this.name)"
/>

function showConfirmDialog(uniqueId) {
$("#dialog-confirm").dialog({
autoOpen: true,
resizable: false,
height: 200,
modal: true,
buttons: {
"Accept": function() {
$(this).dialog("close");
__doPostBack(uniqueId, '');
},
Cancel: function() {
$(this).dialog("close");
}
}
});

return false; // this is to prevent default click handler to cause a postback
}

Codebehind:

protected void ImageButton_Command(object sender, CommandEventArgs e) 
{
// e.CommandArgument will contain the record key and
// e.CommandName will be equal to "Delete" or whatever you'll set on aspx
}

jQuery UI Dialog(Modal), prevents any postback

Finally, I got the answer: Stack Overflow question An ASP.NET button click event is not firing. Thanks to PirateKitten.

All I needed to do was just to add the following just below my dialog creation in JavaScript, and it worked like charm.

$("#editEventModal").parent().appendTo(jQuery("form:first"));

jQuery modal dialog with postbacks in ASP.NET

OK, so this seems to be the fix for jQuery UI v1.10:

$("#newInsurance").dialog({
autoOpen: false,
appendTo: "form",
modal: true
}).parent().css('z-index', '1005');

In jQuery UI v1.10 they added an appendTo property, which seems to do the same exact thing as calling .parent().appendTo($("form")). The trick to the fix is the z-index.

How do I force a postback on an ASP.NET button inside a jQuery modal dialog (div)?

You could force a post back from Javascript:

__doPostBack(id,'');

To do this directly from a control, like a button, use OnClientClick:

<asp:Button id="myButton" runat=server OnClientClick="__doPostBack(id,'');" />

How do I make an ASP.NET postback-confirmation dialog with jQuery?


$(function fn() {

});

U have a dom ready function inside another one.u need to remove the above block...

 $(document).ready(function () {
var $myDialog = $('<div></div>')
.html('You are going to Lock the Record.<br/>Click OK to confirm. Click Cancel to stop this action.')
.dialog({
autoOpen: false,
title: 'Confirm..?',
buttons: { "OK": function () {
$(this).dialog("close");

}, "Cancel": function () {
$(this).dialog("close");

}
}
});
$('<%=Button1.ClientID%>').click(function (e) {
$myDialog.dialog('open');
return false;

});
});

I hope this is right.



Related Topics



Leave a reply



Submit