I have a jQuery UI Dialog working great on my ASP.NET page:
jQuery(function() {
jQuery("#dialog").dialog({
draggable: true,
resizable: true,
show: 'Transfer',
hide: 'Transfer',
width: 320,
autoOpen: false,
minHeight: 10,
minwidth: 10
});
});
jQuery(document).ready(function() {
jQuery("#button_id").click(function(e) {
jQuery('#dialog').dialog('option', 'position', [e.pageX + 10, e.pageY + 10]);
jQuery('#dialog').dialog('open');
});
});
My div:
<div id="dialog" style="text-align: left;display: none;">
<asp:Button ID="btnButton" runat="server" Text="Button" onclick="btnButton_Click" />
</div>
But the btnButton_Click is never called... How can I solve that?
More information: I added this code to move div to form:
jQuery("#dialog").parent().appendTo(jQuery("form:first"));
But still without success...
FWIW, the form:first technique didn't work for me.
However, the technique in that blog article did:
http://blog.roonga.com.au/2009/07/using-jquery-ui-dialog-with-aspnet-and.html
Specifically, adding this to the dialog declaration:
The
$('#dialog').parent().appendTo($("form:first"))
solution works fine in IE 9. But in IE 8 it makes the dialog appear and disappear directly. You can't see this unless you place some alerts so it seems that the dialog never appears. I spend one morning finding a solution that works on both versions and the only solution that works on both versions 8 and 9 is:Hope this helps others that are struggeling with the same issue
I didn't want to have to work around this problem for every dialog in my project, so I created a simple jQuery plugin. This plugin is merely for opening new dialogs and placing them within the ASP.NET form:
So to use the plugin, you first load jQuery UI and then the plugin. Then you can do something like the following:
To be clear, this plugin assumes you are ready to show the dialog when you call it.
ken's answer above did the trick for me. The problem with the accepted answer is that it only works if you have a single modal on the page. If you have multiple modals, you'll need to do it inline in the "open" param while initializing the dialog, not after the fact.
If you do what the first accepted answer tells you with multiple modals, you'll only get the last modal on the page working firing postbacks properly, not all of them.
This was the clearest solution for me
All the content inside the
dlg2
will be available to insert in your database. Don't forget to change thedialog
variable to match yours.