How to use custom Pagelet in asp+

Source: Internet
Author: User
Tags object end join string
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



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.