asp.net生成静态页
先建个html模版页(template.htm):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>$title</title>
</head>
<body>
<table $htmlformat[0] height="100%" border="0" width="100%" cellpadding="10" cellspacing="0" bgcolor="#eeeeee" style="border:1px solid #000000">
<tr>
<td width="100%" valign="middle" align="left">
<span style="color: $htmlformat[1];font-size: $htmlformat[2]">$htmlformat[3]</span>
</td>
</tr>
</table>
</body>
</html>
在asp.net中的应用(c#):
string[] format=new string[4];//定义和htmlyem标记数目一致的数组
StringBuilder htmltext=new StringBuilder();
try
{
using (StreamReader sr= new StreamReader(base.Server.MapPath(".")+"\\template.htm"))
{
String line;
while ((line = sr.ReadLine()) != null)
{
htmltext.Append(line);
}
sr.Close();
}
}
catch
{
Response.Write("<Script>alert('读取文件错误')</Script>");
}
//---------------------给标记数组赋值------------
string title="模板测试";
format[0]="background=\"bg.jpg\"";//背景图片
format[1]= "#990099";//字体颜色
format[2]="150px";//字体大小
format[3]= "<marquee>生成的模板html页面</marquee>";//文字说明
//----------替换htm里的标记为你想加的内容
htmltext.Replace("$title",title);//把title不放在数组是为了比较一下,:)。这样写比较容易看懂
for(int i
相关文档:
前几篇文章介绍了几个国外的.NET CMS,今天就介绍一下国内在ASP.NET平台中比较有特色的pageadmin cms(网址:http://www.pageadmin.net),这个系统并未走传统标签+HTML的路线,直接采用可视化的div+css组合功能模块的设计,大大提供了系统的易用性,下面介绍一下这个系统:
PageAdmin网站内 ......
网站的重定向,通常用的有 301 和 302,301是永久重定向,是对SEO友好的,有利于保持原域名和新域名之间的PR转移及流量数据等。
Asp.Net 中实现301重定向的代码,也是比较简单的,举个例子:
原来的域名是 www.abc.com, 现在要将对这个域名的访问,全部重定向到 www.zu14.cn;
只需在 需要转向的页面里,
protected void ......
1. 当不需要使用Session的时候请关闭
关闭Session当不需要使用的时候
• 若要禁用页的会话状态,请将@ Page 指令中的EnableSessionState 属性设置为false。例如, <%@ Page EnableSessionState="false" %>。
• 注意如果页需要访问会话变量,但不打算创建或修改它们,则将 ......
ASP.NET程序中常用的三十三种代码
1. 打开新的窗口并传送参数:
传送参数:
response.write("<script>window.open(’*.aspx?id="+this.DropDownList1.SelectIndex+"&id1="+...+"’)</script>")
接收参数:
string a = Request.QueryString("id");
string& ......