1.<%%> used to bind background code
Such as:
<%
for (int i=0;i<100;i++)
{
Reaponse.write (i.ToString ());
}
%>
2.<%#%> is executed when the bound control DataBind () method is executed for data binding
such as: <% # Container.DataItem ("title")%>
3.<%=%> The variable or method used to bind the background with a return value, but at this time the variable name or method's access modifier is protected or public
such as:<%=name%> <%=getstr ()%>
4.<%@%> used to import a background namespace
such as: <%@ import namespace= "System.Data" >
5.<%$%> used to bind strings in Web. config (key-value pairs)
such as: <asp:textbox runat= "Server" id= "CC" text= "<%$ connectionstrings:pubs%>" ></asp:TextBox>
Web. config
<configuration>
<system.web>
<compilation debug= "True" targetframework= "4.0"/>
</system.web>
<connectionStrings>
<add name= "Pubs" connectionstring= "server=.; Database=pubs;uid=sa;pwd= "providername=" System.Data.SqlClient "/>
</connectionStrings>
</configuration>
6.DataBind, the data obtained, the system will be implicitly think of the string, how to convert to other types?
Databinder.eval_r (Container.DataItem, "type of conversion", "format") Note: format can not be =eval_r ("type of conversion") for this method
7.<%:%> for direct display of ViewData data in MVC mode
In the action in Eg:controller:
User myuser=new User (); Myuser.link="<a> I am link </a>"; viewdata["model"]=myuser;
This is referred to in the corresponding. aspx:
Links: <%:((MvcAppFirst.Models.User) viewdata["model"]). Link%>
is displayed as text in the page:<a> I am a link </a>
If referenced with <%= ...%>, it is displayed as a hyperlink.
ASP <%%>&<%#%>&<%=%>&<%@%>&<%$%> Usage Differences