2

So I am using ASP.NET 4.5 web forms. I have this form where I want a user to enter data, after the users enters data they should be able to press the next button and they can enter more data.

Is it possible to do this on one ASPX form, or do I need to create another ASPX form.

e.g

Username

Password

--- User clicks the next button---

Email

Phone

--- User clicks finish ---

user673906
  • 757
  • 6
  • 15
  • 30
  • 1
    Why don't you hide the "email" textbox and "phone" textbox? maybe you can put email and phone in a div and set visibility to hidden, then when the user clicks next, show it – User2012384 Mar 13 '15 at 01:21
  • 2
    Yes it's possible in one page. – Rick S Mar 13 '15 at 01:21
  • 2
    Have a look at the [Wizard control](https://msdn.microsoft.com/en-us/library/w7dyf6b5%28v=vs.140%29.aspx). – Lukas S. Mar 13 '15 at 01:24
  • You can have a whole website in "one page". The concept is called a [Single Page Application](http://en.wikipedia.org/wiki/Single-page_application). But Web Forms doesn't lend itself well to that type of application. You'd be better off with a client side MVC framework and a server side framework that can answer [REST](http://en.wikipedia.org/wiki/Representational_state_transfer) calls. – mason Mar 13 '15 at 01:31

4 Answers4

2

Yes this is possible through asp.net Wizard control or MultiView control. You should be able to find these controls in ToolBox under standard category.

To learn more about these controls, please follow these links:

https://msdn.microsoft.com/en-us/library/wdb4eb30(v=vs.140).aspx https://msdn.microsoft.com/en-us/library/ms227665(v=vs.140).aspx

Kiran Varsani
  • 587
  • 5
  • 13
2

Create two divs, one for username and pwd and another for email and phone.

Using jquery 'hide' and 'show' effects you can control both divs, set 'show' for when user click next button.

I am not sure whether this is a right solution for you.

1

Try this:

Initially, I hide the email and phone, when the user clicks next, it set the style to display:block to show the two textboxes

<script>
            function showDiv() {
                document.getElementById('divEmailAndPhone').setAttribute('style', 'display:block');
            }
     </script>
        <form id="form1" runat="server">
            <div>
                <asp:Label runat="server" Text="Username">
                </asp:Label>
                <asp:Label runat="server" Text="Password"></asp:Label>
                <button onclick="showDiv(); return false;">Next</button>
            </div>
            <div id="divEmailAndPhone" style="display:none">
                <asp:Label runat="server" Text="Email"></asp:Label>
                <asp:Label runat="server" Text="Phone"></asp:Label>
            </div>
        </form>
User2012384
  • 4,769
  • 16
  • 70
  • 106
1

you can do it in one page. Just add two other textboxes and set visible false to them.when you press next button change the label text and set visible true to these textbox and hide username and password text box.

farrukh aziz
  • 162
  • 1
  • 2
  • 9