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 %>