前台页面
<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>,如何解决这个问题 请帮个忙 

解决方案 »

  1.   

    <title > <%=lbltitle%></title>lbltitle = ds.Tables[0].Rows[0]["InfoContent"].ToString();调试跟踪下ds.Tables[0].Rows[0]["InfoContent"]的值 里面肯定含有html标签
    方法一: 过滤掉html标签
    方法二: 后台设置标题的控件直接用文本框 这样就不会产生html标签
      

  2.   

    应该是数据库中数据的问题,实在不行,可以前台页面写死<title >厦门咨询公司</title>测试一下。
      

  3.   


    你数据库里存的就应该有P标签可以用Replace直接替换掉P标签
      

  4.   

    lbltitle = ds.Tables[0].Rows[0]["InfoContent"].ToString();
    if(!String.IsNullOrEmpty(lbltitle)) lbltitle =lbltitle.Replace(/<[\/]?p[\s]*?>/,""); 
      

  5.   

    using System.Text.RegularExpressions. lbltitle = Regex.Replace(ds.Tables[0].Rows[0]["InfoContent"].ToString(),"</?p>","");