易截截图软件、单文件、免安装、纯绿色、仅160KB

asp.net生成静态页的方法





1、直接将页面内容存在变量中后输出: 
 StringBuilder IndexContentResult= new StringBuilder(); //存放输出页面的HTML 
 IndexContentResult.Append("<html>\n"); 
 IndexContentResult.Append("  <head>\n");
 IndexContentResult.Append("    <title>title</title> \n");
 IndexContentResult.Append("  </head>\n");
 IndexContentResult.Append("  <body>\n");
 ...
 IndexContentResult.Append("  <body>\n");
 IndexContentResult.Append("</html>\n");
 string tempfile = Server.MapPath("~");
 tempfile = tempfile + "index.htm";
 System.IO.StreamWriter sr = new System.IO.StreamWriter(tempfile, false, System.Text.Encoding.Default);
 sr.Write(IndexContentResult.ToString());
 sr.Close();
2、用模板替换:
 template.htm  //模板文件
 <html>
 <head>
 <title>$title$</title>
 </head>
 <body>
 $body$
 </body>
 </html>
 
 .cs代码文件
 string title = "生成的网页标题";
 string body = "生成的网页内容"; 
 string filename = Server.MapPath("~/") + "frame_a/index.htm"; 
 System.IO.StreamReader srm = new System.IO.StreamReader(filename,System.Text.Encoding.Default);    
 string mb = srm.ReadToEnd();
 srm.Close();
 string tempfile = Server.MapPath("~/") + "index.htm";
 StreamWriter sr = new System.IO.StreamWriter(tempfile, false, System.Text.Encoding.Default);
 mb = mb.Replace("$title$", title);
 mb = mb.Replace("$body$", body);
 sr.Write(mb);
 sr.Close();


相关文档:

ASP.NET的默认调用后台函数

以下是系统自动生成的回调函数
<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['Form1'];
if (!theForm) {
    theForm = document.Form1;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.ons ......

ASP.NET C# 验证码 支持中文 噪点 弯曲

/// <summary>
        /// 根据指定参数返回BitMap对象
        /// 引用如下:
        /// using System.Drawing;
        /// 调用例子如下:
   ......

ASP.NET页面传值_第四篇_Session

例一:
+++ 修改Global.asax文件:
<%@ Application Language="C#" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{  }
void Application_End(object sender, EventArgs e)
{  }
void Application_Error(object sender, EventArgs e)
{  }
void ......

ASP.NET AJAX入门系列

ASP.NET AJAX入门系列将会写关于ASP.NET AJAX一些控件的使用方法以及基础知识,其中部分文章为原创,也有一些文章是直接翻译自官方文档,本部分内容会不断更新。
 
目录
ASP.NET AJAX入门系列(1):概述
    导读:作为本系列文章的开篇,简单介绍一下ASP.NET AJAX的概况及各个组成部分。
  ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号