multiple form submits using updatepanels in asp.net

Can someone please give me some help with using updatepanels in asp.net/ajax? I currently have an asp.net 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">
    <ContentTemplate>
    <table border="0" cellspacing="5" cellpadding="5" width="900px">
        <tr>
            <th>New User</th>
        </tr>
        <tr>
            <td><b>Username:</b></td>
            <td><asp:TextBox ID="txtUsername" runat="server" /></td>
            <td><b>Password:</b></td>
            <td><asp:TextBox ID="txtPassword" runat="server" TextMode="Password" /></td>
        </tr>
        <tr>
            <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>
        </tr>
 <tr>
            <td colspan="4"><asp:Button ID="btnSubmitStep1" runat="server" Text="Next Step" 
                    onclick="btnSubmitStep1_Click" /></td>
        </tr>
    </table>
    </ContentTemplate>
    </asp:UpdatePanel>
<table border="0" cellspacing="5" cellpadding="5" width="900px">
        <tr>
            <th>More Information</th>
        </tr>
        <tr>
            <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>
            </asp:DropDownList></td>
            <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>
            </asp:DropDownList></td>
        </tr>
<tr>
            <td colspan="4"><asp:Button ID="btnSubmitStep2" runat="server" Text="Create Profile" 
                    onclick="btnSubmitStep2_Click" /></td>
        </tr>
</table>
</div>

Open in new window

nuviumAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CoyotesITCommented:
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";
    }
</script>

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.


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
garavindbabuCommented:
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
AJAX

From novice to tech pro — start learning today.