?
Solved

multiple form submits using updatepanels in asp.net

Posted on 2008-11-17
3
Medium Priority
?
771 Views
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">
    <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

0
Comment
Question by:nuvium
2 Comments
 
LVL 8

Accepted Solution

by:
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";
    }
</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
 
LVL 2

Assisted Solution

by:garavindbabu
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.
0

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