asp.net - jQuery Dialog with internal asp:Button dont want it to close the dialog -
question: how stop asp:button lives inside aspx page displayed inside jquery dialog closing dialog. want keep dialog open , use info input form database table work with.
i have simple demo code behind adds 2 numbers (very crude , elementary) , when hit 'button' add numbers closes dialog box. adds numbers dialog box closes.
calling dialog:
<script> function showdialog() { var mydiv = $("#dialog-form").dialog({ modal: true, autoopen: false, height: 500, width: 500 }); mydiv.load('effortsubmittalpage.aspx'); $("#dialog-form").parent().appendto($("form:first")); mydiv.dialog('open'); return false; } </script>
content page displays in dialog:
<asp:content id="headercontent" runat="server" contentplaceholderid="headercontent"> <asp:updatepanel id="wrapper" runat="server" updatemode="conditional"> <contenttemplate> <table id="table1" cellspacing="1" cellpadding="1" width="300" border="0"> <tr> <td> <asp:label id="label1" runat="server">first number:</asp:label> </td> <td> <asp:textbox id="txtfirstnumber" runat="server"></asp:textbox> </td> </tr> <tr> <td> <asp:label id="label2" runat="server">second number:</asp:label> </td> <td> <asp:textbox id="txtsecondnumber" runat="server"></asp:textbox> </td> </tr> <tr> <td> <asp:label id="label3" runat="server">sum:</asp:label> </td> <td> <asp:textbox id="txtsum" runat="server"></asp:textbox> </td> </tr> <tr> <td> <asp:button id="button1" runat="server" text="add numbers" onclick="button1_click"></asp:button> </td> <td></td> </tr> </table> </contenttemplate> </asp:updatepanel> </asp:content>
content code behind
protected void button1_click(object sender, eventargs e) { var inttotal = 0; var intfirstnumber = 0; var intsecondnumber = 0; intfirstnumber = int.parse(txtfirstnumber.text); intsecondnumber = int.parse(txtsecondnumber.text); inttotal = intfirstnumber + intsecondnumber; txtsum.text = inttotal.tostring(); } }
any advice welcome..
andy.
Comments
Post a Comment