码迷,mamicode.com
首页 > 其他好文 > 详细

模板文件概念的引入

时间:2015-07-22 12:28:20      阅读:89      评论:0      收藏:0      [点我收藏+]

标签:

描述:在HTML文件中用某个符号字符串去表示一个标签,在ashx代码中即可用变量名去代替这个标签名

html文件:

<table border="1" cellpadding="0" cellspacing="0">
    <tr>
        <td style="color:Red">姓名</td>
        <td onclick="alert(‘@name你好‘);">@name</td>
    </tr>
    <tr>
        <td>年龄</td>
        <td>@age</td>
    </tr>
</table>

ashx文件:

context.Response.ContentType = "text/html";
string name = "张三";
int age = 20;
string FileName = context.Server.MapPath("~/HTMLPage1.htm");
string Html1 = File.ReadAllText(FileName);
string newHtml = Html1.Replace("@name",name).Replace("@age",age.ToString());
context.Response.Write(newHtml);

 

模板文件概念的引入

标签:

原文地址:http://www.cnblogs.com/genesis/p/4666848.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!