An XML-like code description method is provided in asp+ asp+, such as <asp:label id=test runat=server>
In this article I will give you a description of how to write your own pagelet for example: <asp888:mytestmenu
First we write a ASPC file that must be referenced in the ASPX file
<%@ Page language= "vb"%>
<%@ Import namespace= "System.Drawing"%>
<script runat=server>
' Create a public variable
Public ForeColor as Color
Public BackColor as Color
Public Width as Unit
' Create called functions and procedures
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>
Okay, let's take a look at the aspx file here.
<%@ Page language= "vb"%>
<%@ Register tagprefix= "asp888" tagname= "Mytestcontrol" src= "MENU_CONTROL.ASPC"%>
<script runat=server>
Sub Page_Load (ByVal Sender as Object, ByVal e as EventArgs)
Menucontrol1.addmenuitem ("Tofu Technology Station", "Http://www.asp888.net")
If Page.IsPostBack
Menucontrol1.addmenuitem (Txtnewmenutext.text, Txtnewmenulink.text)
End If
End Sub
</script>
<body>
<asp888:mytestcontrol id= "MenuControl1" Runat=server
BackColor = "Gray"
Width= "100%"
Forecolor= "Silver"/>
<form method=post action=mymenucontrol.aspx runat=server>
<p>
The new join shows:
<asp:textbox Id=txtnewmenutext runat=server/>
</p>
<p>
New Join Address:
<asp:textbox Id=txtnewmenulink runat=server/>
</p>
<p>
<input type=submit value= "Submit" Runat=server/>
</form>
</p>
</body>
After everyone runs, you can see the direct effect of this