欢迎光临
我们一直在努力

如何在ASP+中使用自定义的PAGELET-ASP教程,ASP应用

建站超值云服务器,限时71元/月

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=”menu_control.aspc” %>
<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>  

大家运行后,就可以看到这个的直接效果了

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 如何在ASP+中使用自定义的PAGELET-ASP教程,ASP应用
分享到: 更多 (0)