
Navigator : Home > Tutorials > Controls Tutorials > ...
How to use Panel Control using ASP.NET 2.0 and VB.NET
This tutorial will show you how to use panel control using ASP.NET 2.0 and VB.NET
This tutorial will show you how to use panel control using ASP.NET 2.0 and VB 2.0
If you're ever in the market for some great Windows web hosting, try Server Intellect. We have been very pleased with their services and most importantly, technical support.
This tutorial only using the default namespace.
You need to stuff with your user name in the STEP 1, you will get into next step in the same of page while being to click FristPrevStep button, we use the Visible attribute of panel control to carry out here thus of result.
We use the PrevStep and NextStep event to do the work.
The code as follows.
| Protected Sub PrevStep(ByVal sender As [Object], ByVal e As EventArgs)
Dim CurrentPanel As String = "Panel" + ViewState("PanelSeed").ToString() ViewState("PanelSeed") = CInt(ViewState("PanelSeed")) - 1 Dim PrevPanel As String = "Panel" + ViewState("PanelSeed").ToString() Dim p As Panel = CType(FindControl(CurrentPanel), Panel) p.Visible = False p = CType(FindControl(PrevPanel), Panel) p.Visible = True End Sub
Protected Sub NextStep(ByVal sender As Object, ByVal e As EventArgs)
Dim CurrentPanel As String = "Panel" + ViewState("PanelSeed").ToString() ViewState("PanelSeed") = CInt(ViewState("PanelSeed")) + 1 Dim NextPanel As String = "Panel" + ViewState("PanelSeed").ToString() Dim p As Panel = CType(FindControl(CurrentPanel), Panel) p.Visible = False p = CType(FindControl(NextPanel), Panel) p.Visible = True If CInt(ViewState("PanelSeed")) = 2 Then
FUserName.Text = UserName.Text FAddress.Text = Address.Text FZipCode.Text = ZipCode.Text FComment.Text = Comment.Text End If End Sub |
The front end PanelVB.aspx page looks something like this:
Yes, it is possible to find a good web host. Sometimes it takes a while. After trying several, we went with Server Intellect and have been very happy. They are the most professional, customer service friendly and technically knowledgeable host we've found so far.
<div align="center"><fieldset style="width: 437px"> <asp:Panel id="Panel0" runat="server" Width="434px" > <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse; width: 70%; height: 32px;" bordercolor="#111111"> <tr> <td width="100%" colspan="3" bgcolor="#339966" align="center"> <font color="#ffff99">Step 1 Input user name</font></td> </tr> <tr> <td width="33%" bgcolor="#eeeddb" style="height: 25px"> Username:</td> <td width="33%" bgcolor="#eeeddb" style="height: 25px"> <asp:TextBox id="UserName" runat="Server" Width="156px" /></td> <td bgcolor="#eeeddb" style="width: 34%; height: 25px"> <asp:Button id="FristNextStep" Text="Next step" runat="server" OnClick="NextStep"/></td> </tr> </table> </asp:Panel>
<asp:Panel id="Panel1" runat="server" Width="328px"> <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse; width: 100%;" bordercolor="#111111" height="32"> <tr> <td width="100%" colspan="2" bgcolor="#339966" align="center" style="height: 15px"> <font color="#ffff99">Step 2 Input your information</font></td> </tr> <tr> <td width="33%" bgcolor="#eeeddb" height="16"> Username:</td> <td bgcolor="#eeeddb" height="16" style="width: 79%"> <%=UserName.Text%> </td> </tr> <tr> <td width="33%" bgcolor="#eeeddb" height="16"> Address:</td> <td bgcolor="#eeeddb" height="16" style="width: 79%"> <asp:TextBox id="Address" runat="server" /> </td> </tr> <tr> <td width="33%" bgcolor="#eeeddb" height="16"> ZIP Code:</td> <td bgcolor="#eeeddb" height="16" style="width: 79%"><asp:TextBox id="ZipCode" runat="server" /> </td> </tr> <tr> <td width="33%" bgcolor="#eeeddb" height="16"> Comment:</td> <td bgcolor="#eeeddb" height="16" style="width: 79%"> <asp:TextBox id="Comment" TextMode="MultiLine" Wrap="True" Rows="10" runat="Server" /> </td> </tr> <tr> <td width="33%" bgcolor="#eeeddb" style="height: 16px"> </td> <td bgcolor="#eeeddb" style="width: 79%; height: 16px"> <asp:Button id="FristPrevStep" Text="Previous step" OnClick="PrevStep" runat="server"/>
<asp:Button id="SecondNextStep" Text="Next step" OnClick="NextStep" runat="server" /> </td> </tr> </table> </asp:Panel>
<asp:Panel id="Panel2" runat="server" Width="321px"> <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse; width: 98%;" bordercolor="#111111" height="32"> <tr> <td width="100%" colspan="2" bgcolor="#339966" align="center" style="height: 15px"> <font color="#ffff99">Step 4 Information list</font></td> </tr> <tr> <td width="33%" bgcolor="#eeeddb" height="16"> Username:</td> <td bgcolor="#eeeddb" height="16" style="width: 67%"> <asp:Label id="FUserName" runat="Server" /> </td> </tr> <tr> <td width="33%" bgcolor="#eeeddb" style="height: 16px"> Address:</td> <td bgcolor="#eeeddb" style="width: 67%; height: 16px"> <asp:Label id="FAddress" runat="Server" /> </td> </tr> <tr> <td width="33%" bgcolor="#eeeddb" height="16"> ZIP Code:</td> <td bgcolor="#eeeddb" height="16" style="width: 67%"> <asp:Label id="FZipCode" runat="Server" /> </td> </tr> <tr> <td width="33%" bgcolor="#eeeddb" height="16"> Comment:</td> <td bgcolor="#eeeddb" height="16" style="width: 67%"> <asp:Label id="FComment" runat="Server" /> </td> </tr> <tr> <td width="33%" bgcolor="#eeeddb" height="16"> </td> <td bgcolor="#eeeddb" height="16" style="width: 67%"> <asp:Button id="SecondPrevStep" Text="Previous step" OnClick="PrevStep" runat="server" />
<asp:Button id="FinishStep" Text="Fnish" OnClick="NextStep" runat="server" /> </td> </tr> </table> </asp:Panel> <asp:Panel id="Panel3" runat="server" Width="268px"> <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse; width: 92%;" bordercolor="#111111"> <tr> <td colspan="3" bgcolor="#339966" align="center" style="width: 494px"> <font color="#ffff99">Thank you</font> </td> </tr> <tr> <td colspan="3" bgcolor="#eeeddb" style="width: 494px; height: 20px"> Thank you</td> </tr> </table> </asp:Panel> </fieldset> </div> |
The flow for the code behind page is as follows
Imports System Imports System.Data Imports System.Configuration Imports System.Collections Imports System.Web Imports System.Web.Security Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Web.UI.WebControls.WebParts Imports System.Web.UI.HtmlControls
Partial Class PanelVB
Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
ViewState("PanelSeed") = 0 Panel0.Visible = True Panel1.Visible = False Panel2.Visible = False Panel3.Visible = False End If End Sub Protected Sub PrevStep(ByVal sender As [Object], ByVal e As EventArgs)
Dim CurrentPanel As String = "Panel" + ViewState("PanelSeed").ToString() ViewState("PanelSeed") = CInt(ViewState("PanelSeed")) - 1 Dim PrevPanel As String = "Panel" + ViewState("PanelSeed").ToString() Dim p As Panel = CType(FindControl(CurrentPanel), Panel) p.Visible = False p = CType(FindControl(PrevPanel), Panel) p.Visible = True End Sub Protected Sub NextStep(ByVal sender As Object, ByVal e As EventArgs)
Dim CurrentPanel As String = "Panel" + ViewState("PanelSeed").ToString() ViewState("PanelSeed") = CInt(ViewState("PanelSeed")) + 1 Dim NextPanel As String = "Panel" + ViewState("PanelSeed").ToString() Dim p As Panel = CType(FindControl(CurrentPanel), Panel) p.Visible = False p = CType(FindControl(NextPanel), Panel) p.Visible = True
If CInt(ViewState("PanelSeed")) = 2 Then
FUserName.Text = UserName.Text FAddress.Text = Address.Text FZipCode.Text = ZipCode.Text FComment.Text = Comment.Text End If End Sub End Class |
Looking for the C#.NET 2005 Version? Click Here!
Looking for more ASP.NET Tutorials? Click Here!
We migrated our web sites to Server Intellect over one weekend and the setup was so smooth that we were up and running right away. They assisted us with everything we needed to do for all of our applications. With Server Intellect's help, we were able to avoid any headaches!