Server Intellect
 
Home   Asp.Net Tutorials   What's New   Newsletter   More Resources
 
 
  Categories
Advanced Technologies
AJAX
Internet Browsers
Controls
Database
Email
Error Handling
File
Graphics
Website Navigation
Network
Performance
User Interface and Themes
Validation
Visual Web Developer
Web Services
XML
Suggest Tutorial


Navigator: Home - Tutorials - Controls - How to use Panel Control using ASP.NET 2.0 and VB.NET
How to use Panel Control using ASP.NET 2.0 and VB.NET


ASP.NET Controls Tutorial

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
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

Try Server Intellect for Windows Server Hosting. Quality and Quantity!

The front end PanelVB.aspx page looks something like this:

<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>

We are using Server Intellect and have found that by far, they are the most friendly, responsive, and knowledgeable support team we've ever dealt with!

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

Download the Full Working Version of this Project written with Visual Studio.NET VB 2005 Here!

Looking for the C#.NET 2005 Version? Click Here!

Looking for more ASP.NET Tutorials? Click Here!





 
  Developer Resources







Server Intellect Rocks