如何把数据库里的网站名绑定到 titlec# 的   

解决方案 »

  1.   

    孟子E章的方法在Global.asax.cs里写:   protected   void   Application_BeginRequest(Object   sender,   EventArgs   e)  
      {  
      Response.Write("<title>ok</title>");  
      }
      

  2.   

    思归的办法在每一个页面都添加类似语句好像有点那个吧,  
       
    1、可以在你的Page基类输出javascript:    //read   from   web.config:  
      string   title   =   ConfigurationSettings.AppSettings["title"];  
      string   scriptString   =   "<script   language=JavaScript>document.title='"   +   title   +   "';<";  
      scriptString   +=   "/";  
      scriptString   +=   "script>";  
      if(!IsClientScriptBlockRegistered("PageTitle"))  
      RegisterClientScriptBlock("PageTitle",   scriptString);  
       
    2、或者由Page基类统一输出HTML头尾,参考  
    http://www.codeproject.com/aspnet/page_templates.asp  
      public   class   PageBase   :   System.Web.UI.Page  
      {  
              private   string   _pageTitle;  
              public   string   PageTitle  
              {  
                      get   {   return   _pageTitle;   }  
                      set   {   _pageTitle   =   value;   }  
              }  
       
              protected   override   void   Render(HtmlTextWriter   writer)  
              {  
                      //   First   we   will   build   up   the   html   document,    
                      //   the   head   section   and   the   body   section.  
                      writer.Write(   @"  
                              <html>  
                                      <head>  
                                              <title>"   +   PageTitle   +   @"</title>  
                                      </head>  
                                      <body>"   );  
       
                      //   Then   we   allow   the   base   class   to   render   the    
                      //   controls   contained   in   the   ASPX   file.  
                      base.Render(   writer   );  
       
                      //   Finally   we   render   the   final   tags   to   close  
                      //   the   document.  
                      Writer.Write(   @"  
                                      </body>  
                              </html>"   );  
              }  
      }
      

  3.   

    从数据库读出Title,这个应该不是问题,如果这个有问题,就需要补习基础课了。
      

  4.   

    有没有在aspx文件直接绑定的  <title><%=title %></title>  比如这样
      

  5.   

     this.Header.Title = "你要设计的页面标题";