Interpretation and usage of several similar data binding tags in Asp. Net

Source: Internet
Author: User

Several similar markup symbols in ASP. Net: <% =... %> <% #... %> <% @ %> explanation and usage

 

A: <% #... %>: it is executed when the DataBind () method of the bound control is executed and used for data binding.

 

 

 

For example: <% # Container. DataItem (tit) %>

 

<% = %>: Called during program execution. The background variable value can be displayed, for example :*. in ASPx: <% = aaa %> *. in cs: protected string aaa = Name;

 

<%>: The Inline code block can be found in the page file *. ASPx or *. the following background code is embedded in the ascx file: <% for (int I = 0; I <100; I ++) {Reaponse. write (I. toString () ;}%>

 

<% @ %> The namespace for code Import on the *. ASPx page, for example, <% @ Import namespace = System. Data %>

 

 

<% = %> Can appear anywhere on the page, that is, output, equivalent to <% Response. write () %>, such as <% = DateTime. now. toString () %>
<% # %> It is the binding of data output in the template columns such as GridView, DataList, and Repeater, for example, <% # Eval ("field name") %>
<% $ %> Used to read configuration information in web. config, as shown in <% $ ConnectionStrings: ConnStr %>

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.