Click here to Skip to main content
16,012,223 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a javascript function that opens a popup form on button click. I need help with when user clicks "submit" it needs to fire my vb code behind to insert the data into my database.
I also need help with the submit button to fire the event. Do I do this in the javascript? or on the form in my table?
I haven't used popups much with jquery, so any help would be appreciated, or a different way to accomplish this.
Code Below:

VB
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/jquery-ui.js" type="text/javascript"></script>
<link href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/themes/start/jquery-ui.css"
    rel="stylesheet" type="text/css" />

<script type="text/javascript">
    $("[id*=RegisterButton1]").live("click", function () {
        $("#modal_signup1").dialog({
            width: '325',
            height: '500',
            title: "Start Your 30 Day Trial Here",
            buttons: {
                Close: function () {
                    $(this).dialog('close');
                                },
                                Submit: function () {
                                    $(this).dialog('submit');
                                }
            },
            modal: true
        });
        return false;
    });
</script>

<asp:Button ID="RegisterButton1" runat="server" Text="Register Now!" />

<div id="modal_signup1" style="display: none; font-family: calibri;">
<table style="font-family: calibri; font-size: small; font-weight: bold" 
        align="center">
<tr>
<td>
NPN Number:
</td>
<td>
    <asp:TextBox ID="TextBox1" runat="server" rel="ToolTip" data-placement="bottom" ToolTip="Enter Your NPN Number (You Will Use This To Login)"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Password:
</td>
<td>
    <asp:TextBox ID="TextBox2" runat="server" rel="ToolTip" data-placement="bottom" ToolTip="Enter a Password (You Will Use This To Login)"></asp:TextBox>
</td>
</tr>
<tr>
<td>
First Name:
</td>
<td>
    <asp:TextBox ID="TextBox3" runat="server" rel="ToolTip" data-placement="bottom" ToolTip="Enter Your First Name"></asp:TextBox>
</td>
</tr>
<tr>
<td>
MI:
</td>
<td>
    <asp:TextBox ID="TextBox4" runat="server" rel="ToolTip" data-placement="bottom" ToolTip="Enter Your Middle Initial"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Last Name:
</td>
<td>
    <asp:TextBox ID="TextBox5" runat="server" rel="ToolTip" data-placement="bottom" ToolTip="Enter Your Last Name"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Address:
</td>
<td>
    <asp:TextBox ID="TextBox6" runat="server" rel="ToolTip" data-placement="bottom" ToolTip="Enter Your Address"></asp:TextBox>
</td>
</tr>
<tr>
<td>
City:
</td>
<td>
    <asp:TextBox ID="TextBox7" runat="server" rel="ToolTip" data-placement="bottom" ToolTip="Enter Your City"></asp:TextBox>
</td>
</tr>
<tr>
<td>
State:
</td>
<td>
    <asp:DropDownList ID="DropDownList1" runat="server">
    <asp:ListItem Value="NC" Selected="True">North Carolina</asp:ListItem>
    </asp:DropDownList>
</td>
</tr>
<tr>
<td>
Zip:
</td>
<td>
    <asp:TextBox ID="TextBox8" runat="server" rel="ToolTip" data-placement="bottom" ToolTip="Enter Your Zip Code"></asp:TextBox>
</td>
</tr>
<tr>
<td>
County:
</td>
<td>
    <asp:DropDownList ID="countylist" runat="server" DataSourceID="SqlDataSource2" 
        DataTextField="county" DataValueField="county">
    </asp:DropDownList>
</td>
</tr>
<tr>
<td>
Phone:
</td>
<td>
    <asp:TextBox ID="TextBox9" runat="server" rel="ToolTip" data-placement="bottom" ToolTip="Enter Your Phone Number"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Fax:
</td>
<td>
    <asp:TextBox ID="TextBox10" runat="server" rel="ToolTip" data-placement="bottom" ToolTip="Enter Your Fax Number"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Email:
</td>
<td>
    <asp:TextBox ID="TextBox11" runat="server" rel="ToolTip" data-placement="bottom" ToolTip="Enter Your Email"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2">
Security Question:<br />
What is 2+3? <asp:TextBox ID="TextBox12" runat="server" Width="50"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2">
    <asp:Button ID="SubmitButton" runat="server" Text="Start My Trial Now!"  
        onclientclick="return confirm('Register Now?')" OnClick="SubmitButton_Click" />
</td>
</tr>
<tr>
<td>

</td>
<td>

</td>
</tr>
</table>
</div>
Posted

1 solution

I hope you have a FORM tag which is not there in your code snippet.

You need to do a simple work around to render your DIV inside the FORM tag as jQUERY render the div outside the FORM.

..
$("#modal_signup1").dialog({
..
..
modal: true,

open: function (type, data) {
$(this).parent().appendTo($("form:first"));
}


});
..
..

Hope this will solve your problem.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900