//屏蔽字 词
if (this.CheckBox1.Checked == true)
{
using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLConnString1"].ConnectionString))
{
conn.Open();
//string strsql = "select Username,Userpwd from TB_user where Username='" + txtname.Text + "' or Userpwd='" + txtpwd.Text + "'";
string strSQL = "SELECT text FROM TB_screen";
SqlCommand com = new SqlCommand(strSQL, conn);
SqlDataReader read;
read = com.ExecuteReader();
string str = "";
if (read.Read())
{
str = read["text"].ToString();
}
//ArrayList al = new ArrayList();
//string[] str2 =str.Split(new Char[] { ' ' });//对内容进行拆分,并保存到数组\
//int j = 0;
//foreach (string att in str2)
//{
// al.Add(str2[j]);
// strContent=strContent.Replace(Convert.ToChar(al[j]), '*');
// j++;
//}
//方法二
string[] str3 = str.Split(' ');
foreach (string att in str3)
{
int c = att.Length;
string s = "";
for (int i = 0; i < c; i++)
{
s += "*";
}
strContent = strContent.Replace(att, s);
<!--#include file="conn.asp"-->
<HTML><HEAD><TITLE>生成页面</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<LINK href="style.css" type=text/css rel=stylesheet>
<META content="MSHTML 6.00.2900.3020" name=GENERATOR>
</HEAD>
<BODY bottomMargin=0 leftMargin=0 topMargin=0 rightMargin=0>
<BR style="OVERFLOW: hidden; LINE-HEIGHT: 3px">
<%
dim id
id=cint(request.querystring("id"))
if id="" then
id="1"
else
id=cint(request.querystring("id"))
end if
Dim totalnumber
sql="select id from table order by id DESC"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
rs.Movefirst
if not rs.eof then
TotalNumber=rs.recordcount
end if
获取总数可以用一句代码代替,这个相信朋友自己可以解决.
rs.close
set rs=nothing
<%
Function creat(id)
sql="SELECT * from table where id="&ID
set rs=conn.execute(sql)
dim name
name=rs("name")
conn.execute(sql)
rs.close
set rs=nothing
dim fso
dim znwl
dim art
dim fw
set fso=createobject("scripting.filesystemobject")
set znwl=fso.opentextfile(server.mappath("模板页"))
art=znwl.readall
znwl.close
art=replace(art,"{$name$}",name)
set fw=fso.createtextfile(server.mappath("生成页存放位置及页面名称"),true)
fw.writeline art
fw.close
set fso=nothing
End Function
%>
另外还有一种方法比上面的方法快,但是占用CPU比较多,我的空间用下面的方法老出问题
<!--#include file="conn.asp"-->
<HTML><HEAD><TITLE>生成页面</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<LINK href="style.css" type=text/css rel=stylesheet>
<META content="MSHTML 6.00.2900.3020" name=GENERATOR>
</HEAD>
<BODY bottomMargin=0 leftMargin=0 topMargin=0 rightMargin=0>
<BR style="OVERFLOW: hidden; LINE-HEIGHT: 3px">
<table border="1" width="100%" id="table1">
<tr>
<td>
<%
dim allid,ppp,id,totalnum
sql="select * from table order by id DESC"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
if not rs.eof then
do while not rs.eof
if allid="" then allid= rs("id") else allid= allid & ";" & rs("id")
rs.movenext
loop
else
If Rs.bof And Rs.EOF Then
Response.Write "还没有找到任何文章!"
End if
end if
rs.close
set rs=nothing
allid=";" allid
ppp=split(allid,";")
totalnum=ubound(ppp)
for id=1 to totalnum
Session("id")=Session("id") 1
creat(id)
response.write "正在生成znwl_"&id&".htm...<br>"
next
%>
</td>
</tr>
</table>
</BODY>
</HTML>
<%
Function creat(id)
sql="SELECT * from table where id="&ID
set rs=conn.execute(sql)
dim name
name=rs("name")
conn.execute(sql)
rs.close
set rs=nothing
dim fso
dim znwl
dim art
dim fw
set fso=createobject("scripting.filesystemobject")
set znwl=fso.opentextfile(server.mappath("模板页"))
art=znwl.readall
znwl.close
%>
art=replace(art,"{$name$}",name)
set fw=fso.createtextfile(server.mappath("生成页存放位置及页面名称"),true)
fw.writeline art
fw.close
set fso=nothing
End Function
--------------以下是生成静态网页的类------------
using 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.IO;
using System.Net;
using System.Text;
-------------以下是调用以上类的生成静态网页的实例-------------
using System;
using System.Data;
using System.Configuration;
using System.Collections;
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.IO;
using System.Net;
using System.Text;
using System.Data.OleDb;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{