前台页面
<head id="Head1" runat="server">
<title > <%=lbltitle%></title>
<meta name="keywords" content="厦门市佐谋管理咨询有限公司">
<meta name="description" content="厦门市佐谋管理咨询有限公司">
<META name="author" content="厦门市佐谋管理咨询有限公司">
<--后台代码-->public partial class _Default : System.Web.UI.Page
{
protected string lbltitle;
public static int UId;
MyProjectDAL.DBOperate DBO = new MyProjectDAL.DBOperate();
protected void Page_Load(object sender, EventArgs e)
{
string strSql = "select proPic,c.id as Sid from Products a ,proClass b ,SecondaryClass c where a.tj=true and a.ClassID=b.id and b.SecondaryClassId=c.id order by a.id desc";
DataSet ds = DBO.GetDataSetOleDbCommand(strSql, null);
strSql = "select InfoContent from SiteInfo where InfoName='页面标题'";
ds = DBO.GetDataSetOleDbCommand(strSql, null);
lbltitle = ds.Tables[0].Rows[0]["InfoContent"].ToString();
}
}
但是 页面显示的时候标题上多出了<p></p>,本来应该显示厦门咨询公司,,现在变成<p>厦门咨询公司</p>,如何解决这个问题 请帮个忙
lbltitle = ds.Tables[0].Rows[0]["InfoContent"].ToString();
你可以通过后台
this.Title直接付值,前台没必要写成这样:<title > <%=lbltitle%></title>
{
protected string lbltitle;
public static int UId;
MyProjectDAL.DBOperate DBO = new MyProjectDAL.DBOperate();
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
string strSql = "select proPic,c.id as Sid from Products a ,proClass b ,SecondaryClass c where a.tj=true and a.ClassID=b.id and b.SecondaryClassId=c.id order by a.id desc";
DataSet ds = DBO.GetDataSetOleDbCommand(strSql, null);
strSql = "select InfoContent from SiteInfo where InfoName='页面标题'";
ds = DBO.GetDataSetOleDbCommand(strSql, null);
lbltitle = Regex.Replace(ds.Tables[0].Rows[0]["InfoContent"].ToString(),"</?p>","");
this.Title=lbltitle;
}
}
}
<head id="Head1" runat="server">
<title > <%=lbltitle%></title>
<meta name="keywords" content="厦门市佐谋管理咨询有限公司">
<meta name="description" content="厦门市佐谋管理咨询有限公司">
<META name="author" content="厦门市佐谋管理咨询有限公司">
lbltitle = lbltitle.Replace("<p>","");
lbltitle = lbltitle.Replace("</p>","");