How to submit to the server with JQuery.UI Dialog and ASP.Net?

Posted by Paul on Stack Overflow See other posts from Stack Overflow or by Paul
Published on 2010-01-27T16:17:50Z Indexed on 2010/03/11 19:04 UTC
Read the original article Hit count: 177

Filed under:
|
|

Hi,

I'm looking for a way to submit information captured in a JQuery Dialog to the server in ASP.Net. I originally thought it would work with a 'hidden' asp button, but the click doesn't seem to be submitting the form. Here's the code I have so far:

<script type="text/javascript">
  jQuery(document).ready(function() {

    var dlg = jQuery("#dialog").dialog({
            bgiframe: true,
            autoOpen: false,
            height: 150,
            width: 300, 
            modal: true,
            buttons: {
            "Add": function() {
                    var btn = document.getElementById("<%=btnAdd.ClientID %>");
                    if (btn) btn.click();
                    $(this).dialog("close");
                }
            }
        });

        $("#dialog").parent().appendTo("#dialog_target");

  });
</script>

<div id="hidden" style="visibility:hidden" >

    <!-- Hidden button that actually triggers server add -->
<asp:Button ID="btnAdd" 
            runat="server"
            style="display:none"
            OnClick="btnAdd_Click"  />

<!-- Hidden Delete Dialog -->
<div id="dialog" title="New Additional Skill">
        <label>Additional Skill Name:</label>
        <asp:TextBox ID="_txtNewSkillName" runat="server" />
</div>

Any pointers?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about jQuery