豆腐制作 都是精品
http://www.asp888.net 豆腐技术站
如转载请注明版权信息
*/
asp+ 中提供了一种类似xml 的 代码描写方法,例如<asp:label id=test runat=server
在本篇文章里 我会给大家描述一下 如何 编写自己的pagelet 例如:<asp888:myTestMenu
首先我们写一个aspc 文件,这个文件必须在aspx 文件中进行引用
<%@ Page Language="vb" %
<%@ Import Namespace="System.Drawing" %
<script runat=server
'创建公共变量
Public ForeColor As Color
Public BackColor As Color
Public Width As Unit
' 创建调用的函数和过程
Public Sub AddMenuItem(ByVal IN_Text As String, ByVal IN_URL As String)
Dim NewMenuItem As New TableCell
NewMenuItem.Text = "<a href='" & IN_URL & "'" & IN_Text & "</a"
mySubRow.Cells.Add(NewMenuItem) 'myMenu.Rows(0).Cells.Add(NewMenuItem)
End Sub
Sub Page_Load(ByVal Source As Object, ByVal E As EventArgs)
myASPTable.BackColor = BackColor
myASPTable.Width = Width
myMenu.ForeColor = ForeColor
End Sub
</script
<asp:Table border =1 id=myASPTable runat=server
<asp:TableRow id=myRow1 runat=server
<asp:TableCell id=myMainCell runat=server
<!-- Begin nested menu table --
<asp:Table border=1 id=myMenu runat=server
cellpadding=6
cellspacing=0
<asp:TableRow id=mySubRow
</asp:TableRow
</asp:Table
<!-- End nested menu table --
</asp:TableCell
</asp:TableRow
</asp:Table
好了,下面我们看看aspx 文件
<%@ Page Language="vb" %
<%@ Register TagPrefix="asp888" TagName="myTestControl" src="http://img.jcwcn.com/attachment/portal" %
<html
<head
<script runat=server
Sub Page_Load(ByVal Sender As Object, ByVal e As EventArgs)
menuControl1.AddMenuItem("豆腐技术站", "http://www.asp888.net")
If Page.IsPostBack
menuControl1.AddMenuItem(txtNewMenuText.Text, txtNewMenuLink.Text)
End If
End Sub
</script
</head
<body
<asp888:myTestControl id="menuControl1" runat=server
BackColor = "gray"
Width="100%"
ForeColor="Silver" /
<form method=POST action=myMenuControl.aspx runat=server
<p
新的联结显示:
<asp:TextBox id=txtNewMenuText Runat=server /
</p
<p
新的联结地址:
<asp:TextBox id=txtNewMenuLink Runat=server /
</p
<p
<input type=submit value="Submit" runat=server /
</form
</p
</body
</html
大家运行后,就可以看到这个的直接效果了
作者:豆腐