Razor模板引擎
静心物语313
无痴迷,不成功!
展开
-
Razor模板引擎工作原理及怎么调用外部方法演示
工作原理:RazorEngine引擎就是将cshtml模板文件进行了字符串的拼接,然后,再封装为一个程序集。。。再通过一般处理程序,进行调用。。下面来封装一个方法。来简化上一节内容的操作; 1.获得虚拟路径; 2.从虚拟路径中读取cshtml模板中的内容; 3.给cshtml模板文件取一个别名字;(提高网站性能) 4. 用model替换模板中的变量; 封装一个类步骤:项目名字原创 2015-07-09 14:45:48 · 3100 阅读 · 1 评论 -
Razor模板解密
RazorEngine将模板cshtml编译成了。一个程序集,每次编译运行,都会产生一个程序集; 可以用一个控制台程序打印出来,生成的“动态程序集“的名字(动态程序集是不能打印出磁盘中的位置的)using RazorEngine; using System; using System.Collections.Generic; using System.IO; using System.Linq;原创 2015-07-08 21:11:14 · 649 阅读 · 0 评论 -
Razor模板引擎
为什么使用Reazor原因:类似于前边写的模板页,自己写了。还需要用replace来替换成自己想要的变量。。常见的模板引擎:Razor、Nvelocity、Vtemplate。 Razor有VS自动提示,而且有助于学习asp.net mvc。(Nvelocity、Vtemplate自行学习) Nvelocity。Vemplate 语法在C#中没有自动提示。但是用着非常方便的原创 2015-07-08 17:21:20 · 3152 阅读 · 0 评论 -
自己写一个Raw方法
遇到的的问题 如果在RPcshtmHelper的类中写一个返回值类型是 ‘ string ’类型的方法 public static string Test3() { return "<input type='text' id='name' />"; }在cshtml中调用该方法的话,在浏览器中查看 另一种情况也是如果。在一般处原创 2015-07-09 17:47:19 · 626 阅读 · 3 评论 -
使用Razor拼接一个CheckBox标签
为什么不在cshtm模板页中直接写一个select标签呢?<select> @{ for(int i=0;i<Model.Count;i++) Person p =Model[i]; <option value="@p.Id">@p.Name</option> }原创 2015-07-09 16:47:41 · 1958 阅读 · 0 评论 -
项目练习:自己写一个读取指定html文件的Razor
项目要求练习2:@RPHelper.Include("~/1.html") 把~/1.html内容原样输出到这个位置是项目 ProjectLX001第一步:假定读取的html文件是这个<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content原创 2015-07-15 14:22:03 · 873 阅读 · 0 评论 -
自己写一个DropDownList控件
预备知识:1.关于object.Equals(objA,objB)方法namespace ObjectEqua方法探究 { class Program { static void Main(string[] args) { int i = 1; int j = 1; object o原创 2015-07-15 11:08:58 · 639 阅读 · 2 评论 -
项目练习:自己写一个CheckBoxList,RadioButtonList控件
项目要求 练习1:@RPHelper.CheckBoxList(Model.Persons, "Id", "Name", Model.PersonId) <input type="checkbox" name="managerId" value="1"/><label>rupeng</lable> <br/> <input type="checkbox" name="managerId" value原创 2015-07-15 14:03:50 · 661 阅读 · 0 评论