Tutorials to .com

ASP.NET Development Articles

Can't Find What You're Looking For?

Tutorials to .com » Dotnet » Development » How to use the asp + custom pagelet

How to use the asp + custom pagelet

Print View , by: iSee ,Total views: 16 ,Word Count: 583 ,Date: Tue, 25 Aug 2009 Time: 10:08 PM

/ *
Tofu is fine
http://www.asp888.net technical points such as tofu reproduced please specify copyright information
* /

asp + provides a similar description of xml code, for example, <asp:label id=test runat=server>
In this article, where I will give you describe how to write your own pagelet For example: <asp888: myTestMenu
First, we write a aspc file, the file must be referenced in the aspx file
<% @ Page Language = "vb"%>
<% @ Import Namespace = "System.Drawing"%>
<script runat=server>
Create public variables
Public ForeColor As Color
Public BackColor As Color
Public Width As Unit
Call functions and procedures to create
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>
Well, let's take a look at aspx file
<% @ 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 parks", "http://www.asp888.net")
If Page.IsPostBack
menuControl1.AddMenuItem (txtNewMenuText.Text, txtNewMenuLink.Text)
End If
End Sub
</ script>
</ head>

<asp888: myTestControl id = "menuControl1" runat = server
BackColor = "gray"
Width = "100%"
ForeColor = "Silver" />
<form method=POST action=myMenuControl.aspx runat=server>
The new link shows:
<asp:TextBox id=txtNewMenuText Runat=server />
</ p>
The new link address:
<asp:TextBox id=txtNewMenuLink Runat=server />
</ p>
<input type=submit value="Submit" runat=server />
</ form>
</ p>
</ body>
</ html>
You run, you can see the direct effects of the

Author: tofu ()


Rating: Not yet rated


No comments posted.