multiple form submits using updatepanels in asp.net

Posted on 2008-11-17
Medium Priority
Last Modified: 2012-05-05
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">
    <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

Question by:nuvium

Accepted Solution

CoyotesIT earned 1000 total points
ID: 22978271
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.


Assisted Solution

garavindbabu earned 1000 total points
ID: 22993133
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.

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses
Course of the Month15 days, 16 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question