asp.net 中<% %>、<%@ %>、<%# %>、<%= %>、<%$ %>的用法
来源:互联网 发布:做java工程师有多累 编辑:程序博客网 时间:2024/05/16 08:29
1. <%--exegesics--%> 注释
//相当于<!---->
- <%--注释--%>
2. <% code%> 绑定后台代码块:
//相当于写在后台的可执行代码
- <form id="form1" runat="server">
- <%--绑定后台代码块--%>
- <% for (int i = 1; i <= 10; i++)
- { %>
- <%=i %>
- <%} %>
- </form>
//还可以绑定后台方法<%=NewMethod()%> 也可以写作<%:variable %>
- <form id="form1" runat="server">
- <%=_title %>
- </form>
- namespace WebApplication
- {
- public partial class Index : System.Web.UI.Page
- {
- public string _title = "";
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- _title = "标题";
- }
- }
- }
- }
- <form id="form1" runat="server">
- <asp:Repeater ID="Repeater" runat="server">
- <ItemTemplate>
- <span><%# Eval("name") %></span>
- </ItemTemplate>
- </asp:Repeater>
- </form>
code behind
- this.Repeater.DataSource = null;
5.<%$ %> 绑定web.config的值
- <form id="form1" runat="server">
- <asp:Literal ID="Literal1" runat="server" Text="<%$appSettings:upload_image_path%>" />
- </form>
- <configuration>
- <appSettings>
- <add key="upload_image_path" value="/upload/images/"/>
- </appSettings>
- <system.web>
- <compilation debug="true" targetFramework="4.0" />
- </system.web>
- </configuration>
6. <%@ %>主要用于在web页面定义Page、引入控件、组件、设置Cache等:
- <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="benben.Index" %>
- ASP.NET中$#=的用法
- ASP.NET中$#=的用法
- asp.net 中<% %>、<%@ %>、<%# %>、<%= %>、<%$ %>的用法
- asp.net 中<% %>、<%@ %>、<%# %>、<%= %>、<%$ %>的用法
- 初识ASP.NET---ASP.NET中验证控件的用法
- asp.net中Request.ServerVariables的用法
- asp.net 2.0中GetCallbackEventReference的用法
- Asp.net 中ClientID的用法探讨
- ASP.NET中形式的用法
- asp.net中形式的用法
- ASP.NET中Response的基本用法
- ASP.NET中形式的用法
- asp.net中Content的用法 VS
- ASP.NET中皮肤的用法
- ASP.NET中cookie的用法
- ASP.NET中Cookie的用法
- ASP.NET中using的用法
- asp.net中形式的用法
- pku 3370 Halloween treats(鸽巢原理)
- 封装 继承 多态
- 中国模式其实是不存在的
- eclipse 添加 Courier New 字体
- Extjs4表头及列头事件
- asp.net 中<% %>、<%@ %>、<%# %>、<%= %>、<%$ %>的用法
- 欢迎访问新的技术网站:www.it161.com
- 回溯法
- Find m arrangements from n set
- ubuntu mint 开机启动项管理
- 如何用java写个病毒查杀软件
- 常见MIME类型
- html 两个多选下拉列表元素互相移动
- JAVA-设计模式之适配器模式