ASP. NET 2.0 syntax

Source: Internet
Author: User
1. Instruction syntax
① @ Page command
It can only be contained in the. aspx file. Syntax:
<% @ Page attribute = "value" [attribute = "value"...] %>
②. @ Control command
It can only be contained in the. ascx file (User Control). Syntax:
<% @ Control attribute = "value" [attribute = "value"...] %>
③. @ Import command
Explicitly import a namespace to an ASP. NET application Program File (such as web pages, user controls, master pages), all the classes and interfaces of the imported namespace can be used for files.
<% @ Import namespace = "value" %>
④. @ Implements
Indicates that the current ASP. NET application file implements the specified. NET Framework interface.
<% @ Implements interface = "validinterfacename" %>
⑤. @ Register
⑥. @ Assembly
7. @ reference
Response. @ outputcache

2.CodeDeclare Block <ScriptRunat= "Server"Language= "Codelanguage"SRC= "Pathname">
Code
</Script>

Example: Code
< Html >
< Script Language = "C #" Runat = "Server" >
Void Enterbtn_click (Object SRC, eventargs E)
{
Message. Text
=   " Echo from the wise: Hello! "   + Name. Text +   " I have forgotten for you. Your life will be wonderful. "   +   " <Br> "   +   " And a happy life! But the condition is: you must appreciate yourself, love your life, and make unremitting efforts. " ;
}
</ Script >

< Body >
< Center >
< Form ID = "Form1" Runat = "Server" >
< H4 > Do you want to know what your life is like? </ H4 > < BR />
Enter your name:
< ASP: textbox ID = "Name" Runat = "Server" > </ ASP: textbox >
< ASP: button ID = "Button1" Text = "Submit" Onclick = "Enterbtn_click" Runat = "Server"   />
< P >
< ASP: Label ID = "Message" Runat = "Server" > </ ASP: Label >
</ P >
</ Form >
</ Center >
</ Body >
</ Html >

3. Code rendering Block
Inline code and inline expressions (do not understand) Code
< Html >
< Head Runat = "Server" >
< Title > Fast DEMO code presentation </ Title >
</ Head >
< Body >
< Center >
<%
For ( Int I =   4 ; I <   7 ; I ++ )
{
%>
< Font Size = <% = I % > > The significance of life lies in creation, while struggle is a means. </ Font > < BR />
<% } %>
</ Center >
</ Body >
</ Html >

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.