当前位置: 首页 > 图文教程 > 网络编程 > ASP > asp+语法介绍(三)----asp+的服务器端编程初步

ASP
ASP技巧:让Len,Left,Right函数识别中文
Flash和ASP实现的用户登录/注册程序
ASP随机显示不重复记录解决方案
ASP动态网页制作常用错误处理
ASP对网页进行限制性的访问
初学:ASP内建对象Response
ASP Server object error的解决办法
ASP教程,ASP实现防盗链的方法
更改windows XP 的IIS连接数
xmldom在服务器端生成静态html页面
asp技巧:防止被杀毒软件误删的代码
ASP教程:初步接触ASP缓存技术
ASP教程:rs.getrows的使用方法介绍
ASP技巧:Utf-8和Gb2312乱码问题的终结
ASP教程:applicaton对象的使用集合
ASP环境:启动停止IIS不重启电脑的技巧
利用FLV组件制作的播放器,动态获取变量,控制FLV文件
ASP教程:ASP错误ASP 0201的解决方法
ASP技巧教程:认识学习codepage的属性
Codepage参数和其对应的语言

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 105 ::
收藏到网摘: n/a

       这一章介绍关于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>
&