The Structure of an ASP.NET Page ASP.NET页面的结构(6部分)
Directives指示 两大类Page/Import
Page Directives页指示
语言指示
跟踪指示
Trace class的方法: Write() and Warn().两种方法都可输出文字,区别在于方法1是正常显示,文法2是红色显示.
示例页面 Listing 1.11 Trace.aspx
调试指示
Import Directives导入指示
默认情况下,页面会自动导入了一部分命名空间,如果需要其它命名空间,必须显式的导入,如导入System.Web.Mail命名空间
示例页面Listing 1.12 ImportNamespace.aspx
Code declaration blocks 代码声明部分
代码声明区包含了页面对应的应用程序逻辑,所有的公用变量定义,子过程,函数.包含有类似
参数1 Language表示语言类型,可选参数2 SRC可以指向一个外部文件.
Sub mySub
...subroutine code
End Sub
ASP.NET controls ASP.NET控制区
包含有类似
的标记.可以分区到整个页面各区域.子元素包含有类型 and 的标记.
对于
的标记是很重要的,表示你不可能在一个页面中包含多个Form.Code render blocks 代码块
有inline code and inline expressions 两种用
The value of strSomeText is:
Server-side comments 服务端注释
用表示.
This is inside the comments
--%>
Server-side include directives 服务端包含指示
可以包含外部文件,文件可以是本地的也可以是远程的.所有的包含代码被先执行.
不合法的
注意:可以替代服务端包含指示的是用户控件.
Literal text and HTML tags 文字及HTML标记区
可以在这部分包含ASP.NET的HTML标记, 静态部分可以使用旧的HTML标记和文字.可以使用 LiteralControl 类.
Sub Page_Load
Dim litControl As LiteralControl
For each litControl in Page.Controls
litControl.Text = strReverse( litControl.Text )
Next
End Sub
Literal.aspxThis text is reversed