2) Panels
ASP.NET also introduced panels, these panels are like different areas of the page and you can turn the on and off, or add controls to them. When making multi-page forms you can use panels to show different pages of the form, although it is still on the same page.
<script language="VB" runat="server"> Sub page_load(sender as object, e as EventArgs)
End Sub
Sub Do_page1(sender as object, e as EventArgs) page1.Visible = false page2.Visible = true End Sub Sub Do_Page2(sender as object, e as EventArgs) page2.Visible = false page3.Visible = true End Sub </script> <form runat="server"> <asp:panel runat="Server" id="page1"> Enter your name: <asp:textbox id="name" runat="server" /><br> <asp:button text="Next Page" runat="server" OnClick="Do_page1" /> </asp:panel> <asp:panel runat="server" id="page2" visible="false"> What city do you live in? <asp:textbox id="city" runat="server" /><br> <asp:button text="Finish" runat="server" OnClick="Do_page2" /> </asp:panel> <asp:panel runat="server" id="page3" visible="false" > Thank you for completing the form! </asp:panel> </form> |
Live Demo |
See the Visible=False is set on the other pages and is changed on the Click event handlers. If your wondering what happens to the form values when they're submitted then just check the Viewstate on the last page, it's all there.