ASP. Net connects server code and special symbols on the front-end interface, and asp.net special symbols

Source: Internet
Author: User

ASP. Net connects server code and special symbols on the front-end interface, and asp.net special symbols

1. <%> used to bind background code

For example:

< %    for(int i=0;i<100;i++)    {        Reaponse.Write(i.ToString());    }%>    

 

 

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

For example:

< %# Container.DataItem("title") %>

 

3. <% = %> is used to bind the variables or methods in the background and return values. However, the variable name or method access modifier is protected or public.

For example:

<%=name%> <%=getstr()%>

 

4. <% @ %> is used to import the background namespace

For example, <% @ import namespace = "system. data">

5. <% $ %> is used to bind a string (key-Value Pair) in web. config)

For example:

<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. The data obtained by DataBind will be converted to another type by default as String?

DataBinder. eval_r (Container. DataItem, "Conversion Type", "format") Note: The format can not be this method = eval_r ("Conversion Type ")

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.