CSDN博客

img colayungnew

利用VB.NET设计Web菜单组件

发表于2004/12/30 12:22:00  1374人阅读

  Windows应用程序中往往离不开菜单,菜单的应用是十分普遍了,并且菜单的设计是十分简单的,这主要是因为它已经被编制成组件封装在编程语言中可供直接调用。可是Web程序中要直接用到可供调用的菜单是不可能的,它要编写许多复杂的代码。所以许多WEB程序设计者尽可能避免这些麻烦,用其它功能代替。可是,这样会影响WEB风格甚至降低程序的水准。事实,我们同样可以借签Windows的菜单设计经验开发一个完整的Web菜单组件,全面封装后供用户直接调用,其使用的方便完全与Windows的菜单一样。本人在实践中利用VBasic.Net开发出一个仿真WINDOW菜单,实现WEB上的多级菜单组件。该组件具有灵活、动态、多效果功能,用户可以根据需要设计不同风格的菜单,支持图标,选择行、菜单风格的自设置;图标背景, 背景图片,前背景、动态提示、字体、文字、快捷键等设置。现在把它实现的方法及过程阐述如下:

  实现原理:利用VBasic.Net强大的组件开发功能,把每个菜单行作为一个结点,设置结点的不同属性。在菜单组件的自定义事件中控制菜单所显示的内容,调用对应功能。

  开发步骤如下:

  一、启动Visual Studio.NET。在新建项目中选择Visual Basic项目,在模板中选择类库,在名称中输入类库文件名如MenuNode确定,则进入类库开发环境中,把Class1换名为MenuNode.

  二、定义公共类MenuNode,该类为供应用软件调用。定义类MenuNode的私有变量_ImageUrl,该变量表示结点图片。定义类MenuNode的属性_ParentID,该属性父结点号,分别编写它们的功能。代码如下:

Public Class MenuNode : Inherits TableCell
Private _ImageUrl As String
Private _ParentID As Int16
'父结点号
Public Property ParentID() As Int16
Get
Return ViewState("_ParentID")
End Get
Set(ByVal Value As Int16)
ViewState("_ParentID") = Value
Dim a As TableCell
End Set
End Property
'结点图片
Public Property ImageUrl() As String
Get
Return ViewState("_ImageUrl")
End Get
Set(ByVal Value As String)
ViewState("_ImageUrl") = Value
End Set
End Property
End Class  

  三、定义公共类MenuView,该类定义菜单的主体,属性,方法

  1、定义MenuView类,该类继承WebControl类。由于MenuView类是一个用户自定义类,我们要自定义自己的事件。所以它还需要引用INamingContainer(唯一命名空间接口), IPostBackEventHandler(自定义事件接口)

  代码如下:

Public Class MenuView : Inherits WebControl
Implements INamingContainer
Implements IPostBackEventHandler  

  2、定义MenuView类的一些属性

'背景图片
Dim _BackGround As String
'风格类型
Dim _Type As Int16
'集合下标从1开始,用集合来存放菜单项
Public Shared coll As New Collection()
'定义菜单项的类型:图标型、检测型、检测背景型、普通型
Enum EType
IsImageBackColor = 0
IsCheckBackColor = 1
IsCheck = 2
None = 3
End Enum
'菜单表
Public Shared Index As Int16
'所选择的菜单项指针
Dim _SelectIndex As Int16
'所选择的菜单项背景色
Dim _SelectBackColor As System.Drawing.Color
'图标背景色
Dim _IconBackColor As System.Drawing.Color

Public Property SelectIndex() As Int16
Get
Return _SelectIndex
End Get
Set(ByVal Value As Int16)
End Set
End Property

Public Property SelectBorderStyle() As BorderStyle
Get
Return ViewState("_SelectBorderStyle")
End Get
Set(ByVal Value As BorderStyle)
ViewState("_SelectBorderStyle") = Value
End Set
End Property

Public Property SelectBackColor() As System.Drawing.Color
Get
Return ViewState("_SelectBackColor")
End Get
Set(ByVal Value As System.Drawing.Color)
ViewState("_SelectBackColor") = Value
End Set
End Property
Public Property IconBackColor() As System.Drawing.Color
Get
Return ViewState("_IconBackColor")
End Get
Set(ByVal Value As System.Drawing.Color)
ViewState("_IconBackColor") = Value
End Set
End Property
'
Public Property Type() As EType
Get
Return ViewState("_Type")
End Get
Set(ByVal Value As EType)
ViewState("_Type") = Value
End Set
End Property

Public Property BackGround() As String
Get
Return ViewState("_BackGround")
End Get
Set(ByVal Value As String)
ViewState("_BackGround") = Value
End Set
End Property

  3、定义MenuView类的一些方法


'初使化菜单
Public Sub New()
Me.BackColor = System.Drawing.Color.DeepPink
Me.BorderStyle = BorderStyle.Outset
Me.Width = Unit.Pixel(250)
'Me.Width = Unit.Pixel(50)
Me.BackGround = ""
Me.BorderWidth = Unit.Pixel(0)
Me.Type = 1
End Sub

'自定义OnChange事件,该事件用来表示用户所调用菜单项所完成的功能
Public Event Change As EventHandler
'触发OnChange事件。
Protected Overridable Sub OnChange(ByVal e As EventArgs)
RaiseEvent Change(Me, e)
End Sub
' 当由类实现时,使服务器控件能够处理将窗体发送到服务器时引发的事件。
Public Sub RaisePostBackEvent(ByVal eventArgument As String) Implements IPostBackEventHandler.RaisePostBackEvent
OnChange(New EventArgs())
End Sub

'通过Render方法把组件中的源码直接输出到html文件中,在客户端让IE直接执行。主要要判定出用户所选择的菜单项,分情况处理。显示该菜单体,隐藏其它菜单体。
' /// <summary>
'/// 将此控件呈现给指定的输出参数。
'/// </summary>
'/// <param name="output"> 要写出到的 HTML 编写器 </param>
Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
MyBase.Render(output)
output.Write(Chr(13) + Chr(10))
Dim str As String
str = "<script language='javascript'> " + Chr(13) + Chr(10) & _
"function OpenTable(obj1,index,Type){ " + Chr(13) + Chr(10) & _
" var obj,coll,MenuObj,PareObj; " + Chr(13) + Chr(10) & _
" switch ( Type){ " + Chr(13) + Chr(10) & _
" case 0: //'下菜单 " + Chr(13) + Chr(10) & _
" PareObj=obj1.offsetParent; MenuObj=PareObj.offsetParent; break; " + Chr(13) + Chr(10) & _
" case 1: //'左菜单 " + Chr(13) + Chr(10) & _
" PareObj=obj1.offsetParent; MenuObj=PareObj.offsetParent; break; " + Chr(13) + Chr(10) & _
" case 2: // '无菜单 " + Chr(13) + Chr(10) & _
" PareObj=obj1.offsetParent;MenuObj=PareObj.offsetParent; break;" + Chr(13) + Chr(10) & _
" case 3: " + Chr(13) + Chr(10) & _
" coll=obj1.all.tags('TABLE'); " + Chr(13) + Chr(10) & _
" for (i=1;i<coll.length;i++) " + Chr(13) + Chr(10) & _
" coll[i].style.visibility='hidden';return; " + Chr(13) + Chr(10) & _
" case 4: //'Form " + Chr(13) + Chr(10) & _
" coll= document.all.tags('span'); " + Chr(13) + Chr(10) & _
" for (i=0;i<coll.length ;i++) " + Chr(13) + Chr(10) & _
" { a=coll[i].id.split('_'); " + Chr(13) + Chr(10) & _
" if (a[a.length-1]==obj1) break; } //window.alert (obj1);//var obj1=document.getElementById(obj1); " + Chr(13) + Chr(10) & _
" obj1=coll[i];coll=obj1.all.tags('TABLE'); " + Chr(13) + Chr(10) & _
" for (i=1;i<coll.length;i++) " + Chr(13) + Chr(10) & _
" coll[i].style.visibility='hidden'; return;} " + Chr(13) + Chr(10) & _
" coll=MenuObj.all.tags('TABLE');" + Chr(13) + Chr(10) & _
" for (i=0;i<coll.length;i++) " + Chr(13) + Chr(10) & _
" if (coll[i] ==PareObj ) break; " + Chr(13) + Chr(10) & _
" obj=coll[i+index+1]; " + Chr(13) + Chr(10) & _
" for (j=i+2;j<coll.length;j++) " + Chr(13) + Chr(10) & _
" coll[j].style.visibility='hidden'; " + Chr(13) + Chr(10) & _
" if (Type==2) return; " + Chr(13) + Chr(10) & _
" var top,left,hight,width; " + Chr(13) + Chr(10) & _
" top=obj1.offsetTop;left=obj1.offsetLeft;hight=obj1.offsetHeight; width=obj1.offsetWidth; " + Chr(13) + Chr(10) & _
" while(obj1=obj1.offsetParent) " + Chr(13) + Chr(10) & _
" { top+=obj1.offsetTop; left+=obj1.offsetLeft; } " + Chr(13) + Chr(10) & _
" var PareLeft=obj.offsetParent.offsetLeft;PareTop=obj.offsetParent.offsetTop;PareWidth=obj.offsetWidth; " + Chr(13) + Chr(10) & _
" if (Type==0) " + Chr(13) + Chr(10) & _
" {obj.style.top=top+hight-PareTop; obj.style.left=left-PareLeft;} " + Chr(13) + Chr(10) & _
" else {obj.style.top=top-PareTop; obj.style.left=left+width-PareLeft;} " + Chr(13) + Chr(10) & _
" obj.style.visibility='visible'; " + Chr(13) + Chr(10) & _
" } " + Chr(13) + Chr(10) & _
" </script>" + Chr(13) + Chr(10 output.Write(str)

End Sub
'通知使用基于合成的实现的服务器控件创建它们包含的任何子控件,以便为回发或呈现做准备。
Protected Overrides Sub CreateChildControls()
'生成主菜单
Dim MainTable As New Table()
Dim MainNodes() As MenuNode
MainNodes = Me.GetSubNodes(0)
MainTable = CreateMainMenu(MainNodes)
Me.Controls.Add(MainTable)

'得到子菜单数及每个子菜单的行数
Dim subCount As Int16 = MainNodes.Length - 1

'递规生成子菜单
Dim i As Int16
For i = 0 To subCount - 1
CreateSubMenu(MainNodes(i).ID)
Next

' 透明处理
Me.Attributes("style") = Me.Attributes("style") + ";background-color: transparent "
Me.Attributes("onclick") = "OpenTable(this ,0,3 )"
Dim Form1 = cls.GetParent(Me, "HtmlForm")
Form1.Attributes("onclick") = "OpenTable('" + Me.ID + "',0,4 )"
Me.BorderWidth = Unit.Pixel(0)
'For i = 1 To Me.coll.Count
' Me.coll.Remove(1)
'Next
End Sub

'生成主菜单。由结点生成菜单体
Private Function CreateMainMenu(ByVal Nodes() As MenuNode) As Table
Dim i, j As Int16
'计算父菜单数(及面板数),子菜单数
Dim Count As Int16 = Nodes.Length - 1
Dim Table1 As New Table()
Table1 = Me.CreateTable(1, 2 * Count - 1)
Me.SetTableStyle(Table1)

'生成主表
For i = 0 To Count - 1
Dim Node As New MenuNode()
Node = Nodes(i)
Dim Cell1 As New TableCell()
j = 2 * i
Cell1 = Table1.Rows(0).Cells(j)

'是否有图片,有则生成图片对象,否则生成Label代替
If Node.ImageUrl <> "" Then
Cell1.Controls.Add(Me.CreateImage(Node))
End If

Me.SetCellStyle(Cell1, Node)

'Dim SubName As String
'SubName = Me.ID + "_" + "T%" + Node.ID 'i.ToString
' Me.Parent.Parent.Parent.Parent.Controls()

'鼠标经过时把所有子菜单隐藏(, 把所对应的子菜单显示)
If Me.HasSub(Node) Then
Cell1.Attributes("onmouseover") = "this.style.background='" + Me.GetColorValue(SelectBackColor) + "';OpenTable(this," + i.ToString + ",0 )"
Else
Cell1.Attributes("onmouseover") = "this.style.background='" + Me.GetColorValue(SelectBackColor) + "';OpenTable(this," + i.ToString + ",2 )"

Dim button1 As New LinkButton()
button1.ID = Nodes(i).ID

Me.Controls.Add(button1)
button1.CommandArgument = Nodes(i).ID.ToString
AddHandler button1.Click, AddressOf TableRow_Click

Cell1.Attributes("onclick") = "javascript:__doPostBack('" + Me.ID + ":" + button1.ID + "','')"

End If
Cell1.Attributes("onmouseout") = "this.style.background='" + Me.GetColorValue(Me.BackColor) + "'"

If i < Count - 1 Then
Table1.Rows(0).Cells(2 * i + 1).Width = Unit.Pixel(25)
End If
Next
If Table1.Rows(0).Cells.Count > 0 Then
Table1.Rows(0).Cells(0).ID = "Cell0"
End If
Table1.ID = "T%"
Return Table1
End Function

'递归生成子菜单
Private Sub CreateSubMenu(ByVal ID As Int16)
Dim Nodes() As MenuNode
Nodes = Me.GetSubNodes(ID)
Dim Count As Int16 = Nodes.Length - 1
Dim TableRow(Count) As TableRow
'计算父菜单数(及面板数),子菜单数
Dim Table1 As New Table()
Me.SetTableStyle(Table1)
Dim i As Int16
For i = 0 To Count - 1
Dim Node As New MenuNode()
Node = Nodes(i)

TableRow(i) = New TableRow()
TableRow(i) = Me.CreateMenuItem(Node)

'Dim SubName As String
'SubName = Me.ID + "_" + "T%" + Node.ID ' (Index + Count - 1).ToString

'鼠标经过时把所有子菜单隐藏,把所对应的子菜单显示
If Me.HasSub(Node) Then
TableRow(i).Attributes("onmouseover") = "this.style.background='" + Me.GetColorValue(SelectBackColor) + "';OpenTable(this," + i.ToString + " ,1 )"
Else

TableRow(i).Attributes("onmouseover") = "this.style.background='" + Me.GetColorValue(SelectBackColor) + "';OpenTable(this," + i.ToString + " ,2 )"
Dim button1 As New LinkButton()
button1.ID = Nodes(i).ID
Me.Controls.Add(button1)
button1.CommandArgument = Nodes(i).ID.ToString
AddHandler button1.Click, AddressOf TableRow_Click
If Me.Type = EType.IsCheck Or Me.Type = EType.IsCheckBackColor Then
TableRow(i).Attributes("onclick") = "this.cells(0).text='√'; javascript:__doPostBack('" + Me.ID + ":" + button1.ID + "','')"
Else
TableRow(i).Attributes("onclick") = "javascript:__doPostBack('" + Me.ID + ":" + button1.ID + "','')"

End If
' button1.Attributes("href") = "/"
End If
TableRow(i).Attributes("onmouseout") = "this.style.background='" + Me.GetColorValue(Me.BackColor) + "'"
Table1.Controls.Add(TableRow(i))
Next
Table1.Attributes("style") = "Z-INDEX:999;position:absolute;visibility:hidden ;BACKGROUND-COLOR:" + Me.GetColorValue(Me.BackColor)

Table1.ID = "T%" + ID.ToString 'Index.ToString
Index = Index + 1
Me.Controls.Add(Table1)
For i = 0 To Count - 1
ID = Nodes(i).ID
If Me.HasSub(Nodes(i)) Then
CreateSubMenu(ID)
End If
Next
End Sub

'设置单元格风格
Private Sub SetCellStyle(ByRef cell1 As TableCell, ByVal item As MenuNode)
cell1.BorderStyle = BorderStyle.None
'cell1.BorderWidth = me.BorderStyle
cell1.Enabled = item.Enabled
' cell1.EnableViewState = item.EnableViewState
' cell1.Height = item.Height
cell1.TabIndex = item.TabIndex
cell1.ToolTip = item.ToolTip
cell1.Visible = item.Visible

' cell1.BackColor = Me.BackColor
cell1.Font.Bold = Me.Font.Bold
cell1.Font.Italic = Me.Font.Italic
cell1.Font.Name = Me.Font.Name
cell1.Font.Overline = Me.Font.Overline
cell1.Font.Size = Me.Font.Size
cell1.Font.Strikeout = Me.Font.Strikeout
cell1.Font.Underline = Me.Font.Underline
cell1.ForeColor = Me.ForeColor

cell1.Text = GetHotKeyText(item)
cell1.Wrap = False
End Sub

'设置表的风格
Private Sub SetTableStyle(ByRef Table1 As Table)
'其父是透明的则得到的是其父的父的颜色
'Table1.BorderColor = Me.BackColor ' System.Drawing.Color.White ' .Blue
Table1.Attributes("style") = "Z-INDEX:999;BACKGROUND-COLOR:" + Me.GetColorValue(Me.BackColor)
Table1.Attributes("onmouseover") = "this.style.cursor='hand'"
' Table1.Page.Application.
Table1.BorderColor = Me.BorderColor
Table1.BorderStyle = Me.BorderStyle
Table1.BorderWidth = Unit.Pixel(2)
Table1.Enabled = Me.Enabled
Table1.EnableViewState = Me.EnableViewState
Table1.TabIndex = Me.TabIndex
Table1.ToolTip = Me.ToolTip
Table1.Visible = Me.Visible
Table1.CellPadding = 0
Table1.CellSpacing = 0
End Sub

'生成表格 (row*col)
Private Function CreateTable(ByVal row As Int16, ByVal col As Int16) As Table
Dim Table1 As New Table()
Table1.BackImageUrl = Me.BackGround
Dim i, j As Int16
For i = 0 To row - 1
Dim r As New TableRow()
r = Me.CreateTableRow(col)
Table1.Rows.Add(r)
Next
Table1.Attributes("onmouseover") = "this.style.cursor='hand'"
Return Table1
End Function

'建立菜单项
Private Function CreateMenuItem(ByVal item As MenuNode) As TableRow
Dim TableRow1 As New TableRow()
TableRow1 = Me.CreateTableRow(3)
Select Case Me._Type
Case 0 To 2 'image
TableRow1.Cells(0).BackColor = IconBackColor
' TableRow1.Cells(0).Text = "√"
' Case 1 'check
Case 3 '
End Select

'填充数据
'第一列
'是否有图片,有则生成图片对象,否则生成Label代替
If item.ImageUrl <> "" Then
TableRow1.Cells(0).Controls.Add(Me.CreateImage(item))
End If
TableRow1.Cells(0).Width = Unit.Pixel(22)

'第二列
Me.SetCellStyle(TableRow1.Cells(1), item)

'第三列
TableRow1.Cells(2).Width = Unit.Pixel(30)
If Me.HasSub(item) Then
TableRow1.Cells(2).HorizontalAlign = HorizontalAlign.Right
Me.SetCellStyle(TableRow1.Cells(2), item)
TableRow1.Cells(2).Text = "▶"
End If
Return TableRow1
End Function

'是否有热键,返回有热键的文本
Private Function GetHotKeyText(ByVal item As MenuNode) As String
Dim text As String
text = item.Text
If item.AccessKey <> Nothing Then
text = text + "(<U>" + item.AccessKey + "</U>)"
End If
Return text
End Function

'建立表行(1行,n列)
Private Function CreateTableRow(ByVal n As Int16) As TableRow
Dim TableRow1 As New TableRow()
Dim i As Int16
For i = 0 To n - 1
Dim c As New TableCell()
'Me.SetCellStyle(c)
TableRow1.Cells.Add(c)
Next
Return TableRow1
End Function

'当前索引放在最后一个位置
Private Function GetSubName(ByVal index As Int16, ByVal Count As Int16) As String
Dim i As Int16
Dim Names As String
For i = 0 To Count - 1
Names = Names + Me.ID + "_T" + i.ToString + "|"
Next
Names = Names + Me.ID + "_T" + index.ToString
Return Names
End Function

'由生成一个图标组件
Private Function CreateImage(ByVal item As MenuNode) As Image
Dim Image1 As New Image()
Image1.ImageUrl = item.ImageUrl
'Image1.Enabled = item.Enabled
'Image1.Visible = item.Visible
Return Image1
End Function

Private Sub TableRow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim ID As String = Trim(sender.CommandArgument)
'MessageBox(ID)
_SelectIndex = CType(ID, Int16)
OnChange(e)
End Sub

Private Function HasSub(ByVal item As MenuNode) As Boolean
Dim i As Int16
For i = 1 To coll.Count
If coll.Item(i).ParentID = item.ID Then
Return True
End If
Next
Return False
End Function
'取得ID的所有子结点
Private Function GetSubNodes(ByVal ID As Int16) As MenuNode()
Dim i, j, SubCount As Int16
'计算子菜单数
For i = 1 To coll.Count
If coll.Item(i).ParentID = ID Then
SubCount = SubCount + 1
End If
Next
Dim SubMenuNodeS(SubCount) As MenuNode
'取出子菜子菜单
If SubCount > 0 Then
For i = 1 To coll.Count
If coll.Item(i).ParentID = ID Then
SubMenuNodeS(j) = coll.Item(i)
j = j + 1
End If
Next
End If
Return SubMenuNodeS
End Function

'计算子菜单数
Private Function GetSubCount() As Int16
Dim i, j, SubCount As Int16
'计算父菜单数(及面板数)
For i = 1 To coll.Count
If coll.Item(i).ParentID = 0 Or coll.Item(i).ParentID = Nothing Then
SubCount = SubCount + 1
End If
Next
Return SubCount
End Function

Private Function GetSpace(ByVal count As Short) As String
Dim TxtSb As New System.Text.StringBuilder()
Dim i As Short
For i = 0 To count - 1
TxtSb.Append(" ")
Next
Return TxtSb.ToString
End Function

Private Function GetColorValue(ByVal color1 As System.Drawing.Color) As String
Dim ColorValue As String
Dim r As String = Hex(color1.R)
Dim g As String = Hex(color1.G)
Dim b As String = Hex(color1.B)
If r.Length = 1 Then
r = "0" + r
End If
If g.Length = 1 Then
g = "0" + g
End If

If b.Length = 1 Then
b = "0" + b
End If
ColorValue = r + g + b
Return ColorValue
End Function
'把结点增加到集合中
Public Sub AddNode(ByVal item As MenuNode)
'Dim Form1 = Me.Parent.FindControl(Me.Parent.ID)
'' If Form1 Then
'If Not Form1.IsPostBack Then
coll.Add(item)
'End If
End Sub
Private Sub MessageBox(ByVal Text As String)
Dim Txt As String = "<script>alert('" + Text + "');</script>"
Me.Page.Response.Write(Txt)
End Sub

Protected Overrides Sub Finalize()
MyBase.Finalize()
End Sub
End Class

  四、生成DLL文件

  编写好了所有类,把它生成DLL文件就可。方法是在.net编辑环境下选择生成菜单中按生成就生成了DLL文件。然后,可以直接调用该组件了。

  五、应用与测试

  下面对它进行测试.步骤:

  1.下载本控件。

  2.在ASP.Net开发环境的工具箱中点击自定义工具箱,打开自定义工具箱。

  3.选择".NET框架组件"。

  4.点击浏览,找到刚下载的控件并选择之,点击打开,则控件被引入了。

  5.点击确定,则控件加载到工具箱。

  6.在工具箱中找到该控件并拖到页面窗体中。

  7.设置菜单控件的属性(在属性窗口中)。

  8.导入命名空间:Imports Liyu.Web

  9.编写下面的代码。(假设菜单结点的属性存在表:dt数据表中)


Dim MenuView1 As New MenuView()
For i = 0 To dt.Rows.Count - 1
Dim MenuNode1 As New MenuNode()
MenuNode1.ID = dt.Rows(i)("ID")
MenuNode1.ParentID = dt.Rows(i)("ParentID")
MenuNode1.Text = Trim(dt.Rows(i)("text"))
If Not IsDBNull(dt.Rows(i)("AccessKey")) Then
MenuNode1.AccessKey = dt.Rows(i)("AccessKey")
End If
If Not IsDBNull(dt.Rows(i)("ToolTip")) Then
MenuNode1.ToolTip = dt.Rows(i)("ToolTip")
End If
If Not IsDBNull(dt.Rows(i)("ImageUrl")) Then
MenuNode1.ImageUrl = "tree/" + dt.Rows(i)("ImageUrl")
End If
MenuNode1.Enabled = dt.Rows(i)("Enabled")
MenuView1.AddNode(MenuNode1)Next

  10.在菜单控件的OnChange事件中编写你所选择菜单要完成的功能。


Private Sub MenuView1_Change(ByVal sender As Object,
ByVal e As System.EventArgs)Handles MenuView1.Change
Dim ID As Int16
ID = Me.MenuView1.SelectIndex
Select Case ID
Case 1 ' 首页
Case 4 'asp.net
Case 5 'vb.net
Case 6 'c#
End Select
End Sub

  总结:上面方法用Visual Basic.Net开发了一个Web菜单组件。其开发的复杂程度可想而知,该文开放了所有源代码,并分别作了较详细的解释,大多地方都有注释。通过对上文的学习,能使你掌握如何一个Web组件,Web菜单是怎样实现的,以及编写组件的方法技巧。并为自己深入学习.Net编程提供了多方面知识。

0 0

相关博文

我的热门文章

img
取 消
img即使是一小步
也想与你分享
打开
img