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();
相关文档:
WebBrowser控件 打印2
WebBrowser是IE内置的浏览器控件,无需用户下载.
一、WebBrowser控件
<object ID='WebBrowser' WIDTH=0 HEIGHT=0 CLASSID='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2'></object>
二、WebBrowder控件的方法
//打印
WebBrowser1.ExecWB(6,1);
//打印设置
WebBrowser ......
例一:
+++ 修改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 ......
第一种播放器代码:
<object title="dvubb" align="middle" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" class="object" id="MediaPlayer" width="480" height="360">
<param name="AUTOSTART" value="true"/>
<param name="ShowStatusBar" value="-1"/>
<param name="Filename" va ......
引用自:http://www.cnblogs.com/suzongwei/archive/2008/11/10/1330377.html
或许 这个更易懂些 代码过程
http://blog.csdn.net/swort_177/archive/2007/12/02/1912159.aspx
对于ASP.NET开发者,理解ASP.NET的页面生命周期是非常重要的。
主要是为了搞明白在哪里放置特定的方法和在何时设置各种页面属性。
但是记忆和 ......