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页面中总会遇到比较恼人的麻烦,比如a标签在浏览器下默认的下划线跟字体颜色:
1.在div标签中的a标签和在浏览器下的样式:
2.通过css查找到div里面的a标签,再通过text-decoration属性,去除默认下滑线,color属性添加颜色:
完工。