Write the C # script on the ASP. net aspx page; ASP. NET command ();

Source: Internet
Author: User
Tags net command tagname
    <  H2  > Welcome </  H2  >      <  Ul  >         <%   For  (  Int  I  =  0  ; I  <=  Convert. toint32 (viewdata [  "  Numtime  "  ]); I  ++  ){  %>              < Li  >  <%  =  Viewdata [  "  Message  "  ]. Tostring ()  %>  </  Li  >        <%  }  %>       </  Ul  > 

 

"{" Is part of the language and must be written in <%>

Ii. ASP. NET commands (<% @ %>)

Master, page, control, impot, assembly, reference, etc.

 

<% @ Master %>

Applicable files: Master (master page)

Example: <% master language = "C #" autoeventwireup = "true" codefile = "balloonshop. master. cs" inherits = "balloonshop" %>

 

Attribute name

Function

Autoeventwireup

Whether to automatically bind events (page_load, etc)

Codefile

SpecifyCodeFile

 

 

<% @ Page %>

Applicable files: aspx (ASPX page)

Example: <% page title = "" Language = "C #" masterpagefile = "~ /Balloonshop. Master "autoeventwireup =" true "codefile =" default. aspx. cs "inherits =" _ default "%>

 

 

Attribute name

Function

Autoeventwireup

Whether to automatically bind events (page_load, etc)

Codefile

Code file of the specified page

Language

Language used by the ASPX page (C # Or VB)

Masterpagefile

Master page of The ASPX page

Title

Title of the ASPX page

 

Page title = "Hello World" Language = "C #" masterpagefile = "~ /Balloonshop. Master "autoeventwireup =" true "codefile =" default. aspx. cs "inherits =" _ default"

 

 

<% @ Control %>

Applicable files: ascx (User Control)

Example:

Control Language = "C #" autoeventwireup = "true" codefile = "departmentlist. ascx. cs" inherits = "usercontrols_departmentlist"

Attribute name

Function

Autoeventwireup

Whether to automatically bind events (page_load, etc)

Codefile

Code file of the specified page

Language

Language used by ascx (C # Or VB)

 

 

<% @ Register %>

Applicable files: Master, aspx, and ascx

Purpose: register the ascx control.

Example:

 

<% @ Register src = "~ /Usercontrols/departmentlist. ascx "tagname =" departmentlist "tagprefix =" myascx "%>

 

<Div class = "Left">

<Myascx: departmentlist id = "departmentlist" runat = "server"/>

......

Attribute name

Function

SRC

Uri of the ascx to be introduced

Tagname

Label name of the control

Tagprefix

Control prefix name

 

<% @ Import %>

Purpose: import the namespace

Applicable files: aspx, ascx, and Master

Example:

<% @ Import namespace = "balloonshopbll" %>

Attribute name

Function

Namespace

Namespace to be imported

 

 

<% @ Assembly %>

Applicable files: aspx, ascx, master, and asax

Purpose: SetProgramLinks to ASP. NET application pages (such as web pages, user controls, master pages, or global. asax files) so that all classes and interfaces of the Assembly are available on this page. (Similar to import)

 

Attribute name

Function

SRC

The path of the source file to be dynamically compiled and linked. Use it with the name.

Name

Name of the assembly to be linked. Use it with SRC.

 

 

 

 

 

 

<% @ Outputcache %>

Applicable files: ascx and aspx

Purpose: Set cache policies on the ASPX page or ascx.

Attribute name

Function

Duration

Page or user control cache time (unit: seconds)

Shared

Set whether the user control output can be shared by multiple webpage files. If the value is true, multiple web form pages can access the cached user control output. Optional values: true, false (default). This property is used for user control files (. ascx file ).

 

 

<% @ Reference %>

Applicable files: Mater, aspx, and ascx

Purpose: it is used to link another file (aspx, ascx, etc.). After the link, it can be loaded using the page. loadcontrol method.

Attribute name

Function

Page

The path of the linked webpage file (. aspx file.

Control

The path of the linked user control file (. ascx file.

Virtualpath

The referenced virtual path.

 

 

 

<% @ Previouspagetype %>

Role: commands are used for cross-page transmission.

Attribute name

Function

Typename

Convert the previous webpage to typename and use it with virtualpath.

Virtualpath

Set the previouspage attribute to the type of the virtualpath webpage, and use it with typename.

 

<% @ Mastertype %>

Purpose: When you access an ASP. NET master page through the master attribute, a strong type reference is created for the master page.

Attribute name

Function

Typename

Convert the master to typename and use it with virtualpath.

Virtualpath

Specify the master attribute as the master Type of virtualpath, and use it with typename.

 

<% @ Implements %>

Applicable files: ascx, aspx, and Master

Purpose: What. Net interfaces should be implemented on the current page?

Attribute name

Function

Interface

Interface to be implemented in pages or user controls

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.