前台页面
<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.   

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

  2.   

    单步调试看看这句话得到的值到底是什么
    lbltitle = ds.Tables[0].Rows[0]["InfoContent"].ToString();
    你可以通过后台
    this.Title直接付值,前台没必要写成这样:<title > <%=lbltitle%></title>
      

  3.   

    单调试  显示为 null
      

  4.   

    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)
      {
        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;
        }
      }
        
    }
      

  5.   

    那前台呢前台页面
    <head id="Head1" runat="server">
    <title > <%=lbltitle%></title>
    <meta name="keywords" content="厦门市佐谋管理咨询有限公司">
    <meta name="description" content="厦门市佐谋管理咨询有限公司">
    <META name="author" content="厦门市佐谋管理咨询有限公司"> 
      

  6.   

    后台代码  ,,当前上下文没有 Regex
      

  7.   

    简单的方法你
    lbltitle  = lbltitle.Replace("<p>","");
    lbltitle  = lbltitle.Replace("</p>","");
      

  8.   

    前台直接放个Label标签就好了啊,然后后台赋值,干嘛非要用那种方法绑定呢?