新客网WWW.XKER.COM:致力做中国最专业的网络学院!
学院: 操作系统 - 网络应用 - 服务器 - 网络安全 - 工具软件 - 办公软件 - Web开发 - 数据库 - 网页设计 - 图形图像 - 媒体动画 - 硬件学堂 - 存储频道 - QQ专区
您的位置:首页 > 软件开发 > Web开发 > Asp教程 > 正文:asp+语法介绍(三)----asp+的服务器端编程初步

asp+语法介绍(三)----asp+的服务器端编程初步

新客网 XKER.COM 2003-04-15 来源: 收藏本文
/*
文章出处:http://www.aspCool.com 转载请注明,谢谢!
*/
这一章介绍关于Asp+的服务器端的控件
除了使用<%%>号以外,asp+ 的程序开发者目前可以使用新的标签来生成动态的页面了,新的服务器控可以在asp+ 文件中利用一个特殊的tag runat=server来声明
下面的例子中用到了以下几个服务器控件<form runat=server>, <asp:textbox runat=server>, <asp:dropdownlist runat=server>, and <asp:button runat=server>在运行的过程中他们都会自动生成HTML代码
<html>
<head>
<link rel="stylesheet"href="intro.css">
</head>

<body>

<center>

<form action="intro4.aspx" method="post" runat=server>

<h3> Name: <asp:textbox id="Name" runat="server"/>

Category: <asp:dropdownlist id="Category" runat=server>
<asp:listitem>psychology</asp:listitem>
<asp:listitem>business</asp:listitem>
<asp:listitem>popular_comp</asp:listitem>
</asp:dropdownlist>

<asp:button text="Lookup" runat="server"/>

</form>

</center>

</body>
</html>
这个例子的运行结果在
http://tutorial.superexpert.com/quickstart/aspplus/samples/webforms/intro/intro4.aspx

注意:这些服务器控件都会在客户端生成HTML代码,但是这些服务器控件的内容并没有保存在Hidden 中,而是事实在在 的保存在 页面之间,而且在客户端没有任何的 script 代码

除了这些输入的服务器控件,Asp+ 允许开发者自己去丰富一些定植的控件,例如在下面的例子中我们将要看到的<asp:adrotator>控件就是动态的生成广告图片

<html>
<head>
<link rel="stylesheet"href="intro.css">
</head>

<body>

<center>

<form action="intro5.aspx" method="post" runat="server">

<asp:adrotator AdvertisementFile="ads.xml" BorderColor="black" BorderWidth=1 runat="server"/>

<h3> Name: <asp:textbox id="Name" runat="server"/>

Category: <asp:dropdownlist id="Category" runat=server>
<asp:listitem>psychology</asp:listitem>
<asp:listitem>business</asp:listitem>
<asp:listitem>popular_comp</asp:listitem>
</asp:dropdownlist>

<asp:button text="Lookup" runat="server"/>

</form>

</center>

</body>
</html>
广告文件的内容是:
<Advertisements>

<Ad>
<ImageUrl>/quickstart/aspplus/images/banner1.gif</ImageUrl>
<TargetUrl>http://www.microsoft.com</TargetUrl>
<AlternateText>Alt Text</AlternateText>
<Keyword>Computers</Keyword>
<Impressions>80</Impressions>
</Ad>

<Ad>
<ImageUrl>/quickstart/aspplus/images/banner2.gif</ImageUrl>
<TargetUrl>http://www.microsoft.com</TargetUrl>
<AlternateText>Alt Text</AlternateText>
<Keyword>Computers</Keyword>
<Impressions>80</Impressions>
</Ad>

<Ad>
<ImageUrl>/quickstart/aspplus/images/banner3.gif</ImageUrl>
<TargetUrl>http://www.microsoft.com</TargetUrl>
<AlternateText>Alt Text</AlternateText>
<Keyword>Computers</Keyword>
<Impressions>80</Impressions>
</Ad>

</Advertisements>

这个例子的运行在:
http://tutorial.superexpert.com/quickstart/aspplus/samples/webforms/intro/intro5.aspx
以上是我们对asp+文件的服务器控件的一些简单描述,下面的一讲,我们会讲解一些高级的asp+ 服务器控件的 文章
请大家一如即往的支持我们!

收藏】 【评论】 【推荐】 【投稿】 【打印】 【关闭
发表评论
要记得去论坛讨论,点击注册新会员匿名评论
评论内容:不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
阅读排行
随机推荐
实用信息推荐