ASP <%%>,<%#%>,<%=%>,<%@%>,<%$%> Usage Differences

Source: Internet
Author: User
Tags connectionstrings

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")%>, <%# Eval ("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>

ASP <%%>,<%#%>,<%=%>,<%@%>,<%$%> Usage Differences

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.