public StringBuilder Datatech(string name, string sql)
{
StringBuilder str = new StringBuilder()
DataTable dt = sqlhelper.publicFun("select top 6 * from tb_information where " + sql)
if (dt != null)
{
for (int i = 0i <dt.Rows.Counti++)
{
DataRow dr = dt.Rows[i]
string content = dr["information_Content"].ToString().Trim()
str.Append("<li class='li_KongGe'>" +
"<ul><li>" +
"<img src='images/rili.png' alt=''" + dr["information_Title"] + "'>" +
"<h4>" + Convert.ToDateTime(dr["information_Time"]).ToLongDateString().ToString() + "</h4>" +
"</li>" +
"<li>" +
"<h5><a href='serviceD.html?information_Id=" + dr["information_Id"]+"'>" + dr["information_Title"] + "</a></h5>" +
"<p>" + sqlhelper.ReplaceHtmlTag(content, 40) + "..." + "</p>" +
"</li>" +
"</ul>" +
"</li>")
}
}
return str
}
之所以用string content = dr["information_Content"].ToString().Trim()的作用是去掉所有空格。
去掉html标签: str.replace(/</?[a-zA-Z]+[^><]*>/g,"")去掉标签里面的属性: str.replace(/<([a-zA-Z]+)\s*[^><]*>/g,"<$1>")
上面方法复制进去就行了。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)