ASP.NET前端语法应用

字符拼接
<%# "abc" + Eval("列名").ToString() %>
<%# Eval("列名","abc{0}") %>
格式化
<%# Eval("列名"{0:yyy-MM-dd}") %> //日期格式化
<%# Eval("价格"{0:000.0#}") %> //如果没三位就补0,如001,强制后一位小数 001.0
调用函数
<%# 函数(Eval("列名")) %>

在当前位置输出表达式的值的时候使用<%=UserName %>,不要丢了=
相当于当前位置调用 Response.Write(UserName)
使用的函数,代码相当于在这个位置调用函数,执行代码
注意 aspx中调用cs的成员级别必须是 protected 或者 public ,不能是 private

aspx,cs,dll 之间的关系

在 WebForm(CS文件) 中执行下面的代码
Response.Write(this.GetType() + "<br/>"); //当前执行类的类型名
Response.Write(this.GetType().Assembly.Location + "<br/>"); //当前类所在的Assembly(DLL文件)位置
Response.Write(this.GetType().BaseType + "<br/>"); //当前对象父类的类型名
Response.Write(this.GetType().BaseType.Assembly.Location + "<br/>"); //父类的 Assembly 位置

使用 Reflector打开这个临时dll,反编译这两个类,发现 webform1 是在VS中编写的aspx.cs类
而ASP.webform1_aspx则是一个继承 webform1的子类,ASP.webform1_aspx是根据aspx内容动态
生成的构建内容的类。
当前类是 webform1 ,执行后发现当前执行页面的类名是 ASP.webform1_aspx 这样的类名,父类才是 webform1
说明ASP.webform1_aspx继承了 webform1,所以在 cs中设置成员级别为 private ,在子类中是不可以调用的 

原文地址:https://www.cnblogs.com/yezuhui/p/6842724.html