网站首页 > 网络编程教程 > ASP.NET教程 > ASP.NET 揭秘 ASP.NET页面的结构

ASP.NET 揭秘 ASP.NET页面的结构

  • 作者:互联网
  • 时间:2009-06-30 16:01:37

The Structure of an ASP.NET Page ASP.NET页面的结构(6部分)
 Directives指示 <%@ .... %>两大类Page/Import
  Page Directives页指示
   语言指示<%@ Language="C#" %> <%@ Page Language="C#" %>
   跟踪指示<%@ Trace="True" %> <%@ Page Trace="True" %>
    Trace class的方法: Write() and Warn().两种方法都可输出文字,区别在于方法1是正常显示,文法2是红色显示.
     示例页面 Listing 1.11 Tr***.aspx
   调试指示<%@ Debug="True" %> <%@ Page Debug="True" %>
  Import Directives导入指示
   默认情况下,页面会自动导入了一部分命名空间,如果需要其它命名空间,必须显式的导入,如导入Sy***m.Web.Mail命名空间 <%@ Import Namespace="Sy***m.Web.Mail" %>
    示例页面Listing 1.12 Im***tNamespace.aspx
 Code declaration blocks 代码声明部分
  代码声明区包含了页面对应的应用程序逻辑,所有的公用变量定义,子过程,函数.包含有类似
  
 ASP.NET controls ASP.NET控制区
  包含有类似

的标记.可以分区到整个页面各区域.
  子元素包含有类型 and 的标记.
  对于的标记是很重要的,表示你不可能在一个页面中包含多个Form.
 Code render blocks 代码块
  有inline code and inline expressions 两种用<% %>
   <% strSomeText = "Goodbye!" %>
   The value of strSomeText is:
   <%=strSomeText%>
 Server-side comments 服务端注释
  用<%-- xxxx --%>表示.
   <%--
   This is inside the comments
  
   <%= strSomeText %>
   --%>
 Server-side include directives 服务端包含指示
  可以包含外部文件,文件可以是本地的也可以是远程的.所有的包含代码被先执行.
  
  
   不合法的
  注意:可以替代服务端包含指示的是用户控件.
 Literal text and HTML tags 文字及HTML标记区
  可以在这部分包含ASP.NET的HTML标记, 静态部分可以使用旧的HTML标记和文字.可以使用 LiteralControl 类.
 

 
   <span class="visiblesaf11">Li***al.aspx</span>
 
   This text is reversed