成都网站建设设计

将想法与焦点和您一起共享

ASP.NET中怎么使用模板引擎技术

本篇文章为大家展示了ASP.NET中怎么使用模板引擎技术,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

十载的六枝网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。成都全网营销推广的优势是能够根据用户设备显示端的尺寸不同,自动调整六枝建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联公司从事“六枝网站设计”,“六枝网站推广”以来,每个客户项目都认真落实执行。

Default.aspx这个页面只有几个textbox控件和两个按妞控件

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" ValidateRequest="false" Inherits="ToHtml._Default" %>        Asp.net生成静态页            
         标题:         内容:                                             Url地址:                           
       

要准备的模板页代码,htm文件页面比较简单,如果有兴趣的朋友可以做成更复杂的模板页嘿嘿

!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">        $title$ 生成静态页title>     <style type="text/css"> <!--  .STYLE1 {   font-size: 16px;   font-weight: bold;  }  -->     </style> </head> <body> <br /> <br /> <table width="100%" border="0" bgcolor="#339900">   <tr>     <td height="34" align="center" bgcolor="#FFFFFF"><span class="STYLE1">$title$ </span></td>   </tr>   <tr>     <td height="42" bgcolor="#FFFFFF"><br />       <br />     内容:$content$ </td>   </tr> </table>  </body> </html></pre><p>后台生成静态页面的代码Default.aspx.cs主要用到了文件操做</p><pre>sing System;  using System.Data;  using System.Configuration;  using System.Web;  using System.Web.Security;  using System.Web.UI;  using System.Web.UI.WebControls;  using System.Web.UI.WebControls.WebParts;  using System.Web.UI.HtmlControls;  using System.Net;  using System.Text;  using System.IO;   namespace ToHtml  {      //51aspx.com生成静态页演示文件,转载请保留该信息      public partial class _Default : System.Web.UI.Page      {          protected void Page_Load(object sender, EventArgs e)          {                       }           //根据模板生成,保持在html文件夹中(部分源码搜集于网络)          protected void Button1_Click(object sender, EventArgs e)          {              //源码是替换掉模板中的特征字符               string mbPath =Server.MapPath("template.htm");              Encoding code = Encoding.GetEncoding("gb2312");              StreamReader sr = null;              StreamWriter sw = null;              string str = null;               //读取              try             {                  sr = new StreamReader(mbPath, code);                  str = sr.ReadToEnd();               }              catch (Exception ex)              {                  throw ex;              }              finally             {                  sr.Close();              }               //根据时间自动重命名,扩展名也可以自行修改              string fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + ".htm";              str = str.Replace("$title$", txtTitle.Text);//替换Title              str = str.Replace("$content$", txtContent.Text);//替换content               //生成静态文件              try             {                  sw = new StreamWriter(Server.MapPath("htm/") + fileName, false, code);                  sw.Write(str);                  sw.Flush();               }              catch (Exception ex)              {                  throw ex;              }              finally             {                  sw.Close();                  Response.Write("恭喜<a href=htm/"+fileName+" target=_blank>"+fileName+"</a>已经生成,保存在htm文件夹下!");              }            }            //根据Url地址生成静态页保持          protected void Button2_Click(object sender, EventArgs e)          {              Encoding code = Encoding.GetEncoding("utf-8");              StreamReader sr = null;              StreamWriter sw = null;              string str = null;               //读取远程路径              WebRequest temp = WebRequest.Create(txtUrl.Text.Trim());              WebResponse myTemp = temp.GetResponse();              sr = new StreamReader(myTemp.GetResponseStream(), code);              //读取              try             {                  sr = new StreamReader(myTemp.GetResponseStream(), code);                  str = sr.ReadToEnd();               }              catch (Exception ex)              {                  throw ex;              }              finally             {                  sr.Close();              }              string fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + ".html";               //写入              try             {                  sw = new StreamWriter(Server.MapPath("htm/") + fileName, false, code);                  sw.Write(str);                  sw.Flush();               }              catch (Exception ex)              {                  throw ex;              }              finally             {                  sw.Close();                  Response.Write("恭喜<a href=htm/" + fileName + " target=_blank>" + fileName + "</a>已经生成,保存在htm文件夹下!");              }           }      }  }</pre><p>上述内容就是ASP.NET中怎么使用模板引擎技术,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注创新互联行业资讯频道。</p>            
            
                                <br>
                    本文标题:ASP.NET中怎么使用模板引擎技术                    <br>
                    文章分享:<a href="http://chengdu.cdxwcx.cn/article/pgcios.html">http://chengdu.cdxwcx.cn/article/pgcios.html</a>
                </div>
            </div>
        </div>
        <!--左边end-->
        <!--右边begin-->
        <div class="news_r">
            <div class="news_t"><h2 class="h2">其他资讯</h2></div>
            <div class="news_ul3">
                <ul>
                    <li>
                            <a href="/article/didhhi.html">
                                <h3 class="h3">用python打开文件的方法-创新互联</h3>
                            </a>
                        </li><li>
                            <a href="/article/dicoss.html">
                                <h3 class="h3">在服务器上建立站点的方法步骤-创新互联</h3>
                            </a>
                        </li><li>
                            <a href="/article/dicose.html">
                                <h3 class="h3">如何解决Python3下map函数的显示问题-创新互联</h3>
                            </a>
                        </li><li>
                            <a href="/article/dicooi.html">
                                <h3 class="h3">Python中xlrdexcel文件操作的示例分析-创新互联</h3>
                            </a>
                        </li><li>
                            <a href="/article/dicode.html">
                                <h3 class="h3">PHP命名空间的使用方法-创新互联</h3>
                            </a>
                        </li>                </ul>
            </div>
        </div>
        <!--右边end-->
        <div class="c_l"></div>
    </div>
</div>
<!--正文end-->
<!--尾部begin-->
<!--尾部begin-->
<footer>
    <div class="f_bg">
        <div class="wrap">
            <div class="links">
                <h2 class="h2">甜橘子解决方案<a href="/solution/" title="更多" class="more">更多+</a></h2>
                <ul>
                    <li><a href="/solution/xiaochengxu.html" title="小程序定制解决方案">小程序定制解决方案</a></li>
                    <li><a href="/solution/qiyewz.html" title="企业网站建设解决方案">企业网站建设解决方案</a></li>
                    <li><a href="/solution/menhuwz.html" title="行业门户网站建设解决方案">行业门户网站建设解决方案</a></li>
                    <li><a href="/solution/yingxiaowz.html" title="营销型网站建设解决方案">营销型网站建设解决方案</a></li>
                    <li><a href="/solution/waimaowz.html" title="外贸网站建设解决方案">外贸网站建设解决方案</a></li>
                    <li><a href="/solution/pingpaiwz.html" title="品牌形象网站建设解决方案">品牌形象网站建设解决方案</a></li>
                    <li><a href="/solution/dianziwz.html" title="数码、电子产品网站建设解决方案">数码、电子产品网站建设解决方案</a></li>
                    <li><a href="/solution/jituanwz.html" title="集团、上市企业网站建设解决方案">集团、上市企业网站建设解决方案</a></li>
                    <li><a href="/solution/dichanwz.html" title="房地产、地产项目网站建设解决方案">房地产、地产项目网站建设解决方案</a></li>
                    <li><a href="/solution/zhubaowz.html" title="珠宝高端奢侈品网站建设解决方案">珠宝高端奢侈品网站建设解决方案</a></li>
                </ul>
            </div>
            <div class="links w2">
                <h2 class="h2">我们的实力<a href="/about/" title="更多" class="more">更多+</a></h2>
                <ul>
                    <li>10年专业互联网服务经验</li>
                    <li>成都高端建站设计团队</li>
                    <li>资深行业分析策划</li>
                    <li>B2C营销型网站建设者</li>
                    <li>前沿视觉设计、研发能力</li>
                    <li>前端代码深度符合SEO优化</li>
                    <li>成都市高新技术企业证书</li>
                    <li>具有完备的项目管理</li>
                    <li>完善的售后服务体系</li>
                    <li>深厚的网络运营经验</li>
                    <li>时刻新技术研发能力</li>
                    <li>16个网站系统软件著作权</li>
                </ul>
            </div>
            <div class="f_div2_r">
                <h2 class="h2">关于甜橘子<a href="/about/" title="更多" class="more">更多+</a></h2>
                甜橘子网站设计,为客户量身定制各类网站建设业务,包括企业型、电子商务型、行业门户型、品牌建立型等各类网站,实战经验丰富,成功案例众多。以客户利益为出发点,甜橘子网站制作为客户规划、定制符合企业需求、带有营销价值的建站方案,提供从网站前期定位分析策划到网站界面设计... </div>
            <div class="c_l"></div>
        </div>
        <div class="wrap">
            <div class="f_div3"> <span class="l">成都网站制作案例©2020 甜橘子设计 版权所有  | <a href="http://chengdu.cdxwcx.cn" target="_blank">甜橘子网站设计</a><a href="http://chengdu.cdxwcx.cn" target="_blank">chengdu.cdxwcx.cn</a></span> <span class="r"><a href="https://beian.miit.gov.cn/" target="_blank" rel="nofollow">蜀ICP备11025516号</a></span> </div>
        </div>
    </div>
</footer>
<!--尾部end-->
<script language="javascript" src="/Public/Home/js/foot.js"></script>
<!--尾部end-->
<!--侧边栏begin-->
<div class="side">
    <ul>
        <li id="qqonline_xbceo"><a href="tencent://message/?uin=631063699&Site=&Menu=yes"><i class="bgs1"></i>QQ咨询</a></li>
        <li class="shangqiao"><a href="tencent://message/?uin=532337155&Site=&Menu=yes" title="在线咨询">
            <div><i class="bgs2"></i>在线咨询</div>
        </a></li>
        <li class="sideewm"><i class="bgs3"></i>官方微信
            <div class="ewBox"></div>
        </li>
        <li class="sideetel"><i class="bgs4"></i>联系电话
            <div class="telBox">
                <dd class="bgs1"><span>座机</span><a href="tel:028-86922220" target="_blank">028-86922220</a></dd>
                <dd class="bgs2"><span>手机</span><a href="tel:13518219792" target="_blank">13518219792</a></dd>
            </div>
        </li>
        <li class="sidetop" onClick="goTop()" id="sidetop"><i class="bgs6"></i>返回顶部</li>
    </ul>
</div>
<script type="text/javascript">
    $('.sideewm').hover(function(){
        $('.ewBox').stop().fadeIn();
    },function(){
        $('.ewBox').stop().fadeOut();
    });
    $('.sideetel').hover(function(){
        $('.telBox').stop().fadeIn();
    },function(){
        $('.telBox').stop().fadeOut();
    });
    $(".con_id img").each(function(){
        var src = $(this).attr("src");    //获取图片地址
        var str=new RegExp("http");
        var result=str.test(src);
        if(result==false){
            var url = "https://www.cdcxhl.com"+src;    //绝对路径
            $(this).attr("src",url);
        }
    });
</script>
<!-- WPA start -->
<!-- WPA end -->
<!--侧边栏end-->
</body>
</html>