multiple form submits using updatepanels in

Can someone please give me some help with using updatepanels in I currently have an form, which has 2 main sections. Previously, each section was its own form on its own separate page. I want both sections on the same page, with the second hidden from view until the first one is completed.

In the code snippet, you'll see that I have an update panel currently surrounding the first section of the form. When the submit button is hit, I want to save all the fields in hidden fields or variables (or whatever is the best practice) and hide its visibility, then make the second form visible in the same screen space. On submitting the second form, thats when I perform my query to the database and move off the page. The backend of the pages is in C#.
<div id="formContent">
<asp:UpdatePanel ID="upRegStep1" runat="server">
    <table border="0" cellspacing="5" cellpadding="5" width="900px">
            <th>New User</th>
            <td><asp:TextBox ID="txtUsername" runat="server" /></td>
            <td><asp:TextBox ID="txtPassword" runat="server" TextMode="Password" /></td>
            <td><b>First Name:</b></td>
            <td><asp:TextBox ID="txtFirstName" runat="server" /></td>
            <td><b>Password Confirm:</b></td>
            <td><asp:TextBox ID="txtPasswordConfirm" runat="server" TextMode="Password" /></td>
            <td colspan="4"><asp:Button ID="btnSubmitStep1" runat="server" Text="Next Step" 
                    onclick="btnSubmitStep1_Click" /></td>
<table border="0" cellspacing="5" cellpadding="5" width="900px">
            <th>More Information</th>
            <td><b>Marital Status:</b></td>
            <td><asp:DropDownList ID="ddlMarital" runat="server">
            <asp:ListItem Value="Single">Single</asp:ListItem>
            <asp:ListItem Value="Married">Married</asp:ListItem>
            <asp:ListItem Value="Divorced">Divorced</asp:ListItem>
            <td><b>Yearly Income:</b></td>
            <td><asp:DropDownList ID="ddlYearlyIncome" runat="server">
            <asp:ListItem Value="020k">$0 - $20,000</asp:ListItem>
            <asp:ListItem Value="2050k">$20,000 - $50,000</asp:ListItem>
            <asp:ListItem Value="50100k">$50,000 - $100,000</asp:ListItem>
            <asp:ListItem Value="100k+">$100,000 +</asp:ListItem>
            <td colspan="4"><asp:Button ID="btnSubmitStep2" runat="server" Text="Create Profile" 
                    onclick="btnSubmitStep2_Click" /></td>

Open in new window

Who is Participating?
CoyotesITConnect With a Mentor Commented:
I would just wrap your part1 in a div and call a javascript function to hide that div and display the second part of your form. Then use your  to handle the actual submit of your form.

<script language="javascript">
    function goToPart2() {
        document.getElementById("formPart1").style.display = "none";
        document.getElementById("formPart2").style.display = "block";

then your just call .... onclick="javascript:goToPart2();" />

from your btnSubmitStep1 but instead of using the asp:button, just use a standard <input type="button" ... and then use the asp:button for your actual submit to commit the data.

garavindbabuConnect With a Mentor Commented:
The other easy option is to place the contents of each part in asp:panels and make visible to false or true depending on user actions.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.