就是如何让页面HTML的<title>???</title>的???显示为aspx.cs里的Label绑定的值?

解决方案 »

  1.   

    同时我将Waiting online~~问题解决就给分Over!~
      

  2.   

    <script>
    s="mytitle";
    document.title = s;
    </script>
      

  3.   

    Page.Header.Title = "你要的值";try
      

  4.   

    <title>
    <%=title%>
    <title>xxx.cs
    public string title="ASD";
      

  5.   

    document.title = document.getElementById(labelid).value;
      

  6.   

    Page.Header.Title = "你要的值";
    绝对行,我测试通过
      

  7.   

    浩子?Are you sure ?
      

  8.   

    <title><%#Label1.Text %></title>
    Page_Load:Page.DataBind();
      

  9.   

    1、
    Page.Header.Title = "你要的值";
    绝对行,我测试通过2、
    <title><%=title%><title>CS代码
    public string strtitle="";private void Page_Load(object sender, EventArgs e)
    {
    // 在此处放置用户代码以初始化页面
    if(!Page.IsPostBack)
    {
    strtitle="ssss";
    }
    }
      

  10.   

    sure 
      protected void Page_Load(object sender, EventArgs e)
            {
                Page.Header.Title = "testHeader";
    page_Load里试的,VS2005 调试环境
      

  11.   

    也可以<asp:Panel id="aaa" runat="server">
        <title><%#Label1.Text %></title>
     </asp:Panel>Page_Load:aaa.DataBind();
      

  12.   

    下面的方法是Label邦定AAA,然后再邦定title<%@ Page Language="C#" AutoEventWireup="true" CodeFile="_a.aspx.cs" Inherits="_a" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <asp:Panel id="aaa" runat="server">
        <title><%#Label1.Text %></title>
     </asp:Panel>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
          <asp:Label ID="Label1" runat="server" Text="<%#AA %>"></asp:Label></div>
        </form>
    </body>
    </html>using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;public partial class _a : System.Web.UI.Page
    {
        public string  AA = "ok";
        protected void Page_Load(object sender, EventArgs e)
        {
          Label1.DataBind();
          aaa.DataBind();    }
    }
      

  13.   

    再加一条,如果需要动态改变title的该如何继续?
      

  14.   

    "动态改变title" ---- 我的网站是用js写的:document.title。参见我的网站http://www.123du.com
      

  15.   

    Q: aspx.cs里的Label绑定的值
    ——————————————————————————————————————————
    A: 这不等于aspx里边的<asp:Label>的值!不论是aspx还是ascx或者自定义控件,你都可以这样写:  this.Page.ClientScript.RegisterStartupScript(this.GetType(),"setTitle",
       "window.document.title='" + yourLabel.Text.Replace("'","\\'")+"';");
      

  16.   

    对于asp.net2.0,使用Title属性也不错的。
      

  17.   

    <title><%# xxxxx%></title>public string xxxxx()
    {
       return ....
    }
      

  18.   

    <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server" id="Head1">
        <title>无标题页</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:Label ID="LblHead" runat="server" Text="第一次加载."></asp:Label>&nbsp;
            <asp:TextBox ID="TxtHead" runat="server"></asp:TextBox>
            <asp:Button ID="BtnHead" runat="server" OnClick="BtnHead_Click" Text="Change Title" /></div>
        </form>
    </body>
    </html>using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;public partial class _Default : System.Web.UI.Page 
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //初始Title
            this.Head1.Title = LblHead.Text;
        }
        /// <summary>
        /// 更改Title
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void BtnHead_Click(object sender, EventArgs e)
        {
            this.Head1.Title = TxtHead.Text;
        }
    }
      

  19.   

    用数据绑定:
    <asp:Panel id="Label1" runat="server">
        <title><%#Label1.Text %></title>
     </asp:Panel>
    Label1.DataBind();
      

  20.   

    至少有5、6种简洁准确的写法。我再补充分别在两个版本asp.net上的两种写法:在asp.net2.0下,可以这样:
      <title runat="server" id="mytitle">无标题页</title>
    这时候代码中就立刻出现了mytitle控件,并且它的类型就是 HTMLTitle,所以使用Text属性设置标题内容。在asp.net1.1下,设计器上的写法与上边一样,但是codebehind代码中必须要自己声明其类型:
      protected HtmlGenericControl mytitle;
    然后就可以直接操纵标题控件(因为页面会给这个变量传递准确的控件)。由于是HtmlGenericControl 类型,所以使用InnerText属性设置标题内容。
      

  21.   


    <title><%=title%><title>CS代码
    public string strtitle="";private void Page_Load(object sender, EventArgs e)
    {
    // 在此处放置用户代码以初始化页面strtitle="ssss";}
      

  22.   

    <title><%# Label1.Text %></title>
    最简单方便的方法!
      

  23.   

    http://www.quandi.cn/WebForm1.aspx?quandi_id=lxzm1001不会笑掉牙的!因为不敢笑
      

  24.   

    要分!!<head runat="server">
        <title><%= Label1.Text %></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        <asp:Label ID="Label1" Text="abc" runat="server"></asp:Label>
        </div>
        </form>
    </body>
      

  25.   

    ASP.NET 1.x:
    <title id="Titile" runat="server"></title>
    之后你就直接操作Page.Title.InnerHTML吧,因为服务器端已经将它识别为一个通用控件。需要注意的是,VS遇到这样的页面会主动帮你把它改回<title></title>。ASP.NET 2.0:
    官方引入了上述机制,整个Header就是一个控件,Page.Header.Title直接操作就是了。
      

  26.   

    我今天刚看了书
    正好是数据绑定
    这属于 绑定简单变量
    语法为:<%#Name#>
    <asp:label text='<%#Label.text>' runat="server"/>