asp.net uncover ASP. NET page structure

Source: Internet
Author: User
Tags comments contains html tags include mail
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>



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.