Asp.net| page
The Structure of an asp.net Page ASP. NET page structure (6 parts)
Directives Instructions <%@ ...%> two major categories Page/import
Page Directives pages indicate
Language instruction <%@ language= "C #"%> <%@ Page language= "C #"%>
Trace indicates <%@ trace= "true"%> <%@ Page trace= "true"%>
Trace class Method: Write () and Warn (). Two methods can output text, the difference is that Method 1 is normal display, grammar 2 is red display.
Sample Page Listing 1.11 trace.aspx
Debug indicates <%@ debug= "true"%> <%@ Page debug= "true"%>
Import Directives Instructions
By default, the page automatically imports part of the namespace, and if additional namespaces are required, you must import them explicitly, such as importing the System.Web.Mail namespace <%@ import namespace= "System.Web.Mail"%>
Sample page Listing 1.12 importnamespace.aspx
Code Declaration Blocks Declaration Section
The code declaration area contains the corresponding application logic for the page, all public variable definitions, subroutines, functions. Contains tags similar to the <script runat= "Server" >.
Parameter 1 language represents the language type, optional parameter 2 src can point to an external file.
<script runat= "Server" src= "applicationlogic.aspx"/>
<script language= "C #" runat= "Server" >
</Script>
<script runat= "Server" >
Sub mysub
... subroutine code
End Sub
</Script>
asp.net controls ASP. NET control Area
Contains tags similar to the <form runat= "Server" >. You can partition to the entire page area.
The child element contains tags that have type <span runat= "Server" > and <asp:label runat= "Server"/>.
It is important to mark the <form runat= "Server" > that you cannot include multiple form on a single page.
Code Render blocks Block
There are inline code and inline expressions two kinds of <%%>
<% strsometext = "goodbye!"%>
The value of Strsometext is:
<%=strSomeText%>
Server-side Comments Service-side annotations
With <%--xxxx--%> said.
<%--
This is inside the comments
<asp:label text= "Hello!" runat= "Server"/>
<%= Strsometext%>
--%>
Server-side include directives service side contains instructions
Can contain external files, files can be local or remote. All of the included code is executed first.
<!--#INCLUDE file= "includefile.aspx"-->
<!--#INCLUDE virtual= "/mydirectory/includefile.aspx"-->
Illegal <!--#INCLUDE file= "<%=myVar%>"-->
Note: You can override the service side to include the user control that is indicated.
Literal text and HTML tags text and HTML markup area
You can include asp.net HTML tags in this section, and the static part can use old HTML tags and text. You can use the LiteralControl class.
<script runat= "Server" >
Sub Page_Load
Dim Litcontrol as LiteralControl
For each litcontrol in Page.controls
Litcontrol.text = StrReverse (Litcontrol.text)
Next
End Sub
</Script>
<body>
<b>this text is reversed</b>
</body>