在 AppWeb_Allcate.ascx.cs 下
    protected void Page_Load(object sender, EventArgs e)
    {
        string KeyWord = "大家好"
    }
在 Index.aspx 页面里引用 AppWeb_Allcate.ascx.cs 请问怎样在 AppWeb_Allcate.ascx.cs 的 Page_Load里设置 Index.aspx的
<meta name="keywords" runat="server" id="keywords" 
 content="如何设置content = '大家好' "/>

解决方案 »

  1.   

    trykeywords.Attributes.Add("content",KeyWord )
      

  2.   

    随便找个地方 Response.Write("<meta name=\"keywords\" id="keywords" content = \"大家好\" >")只要不写在表格里,写在页面的任何地方应该都行。
      

  3.   

    HtmlMeta hm = new HtmlMeta();
            hm.Name = "keywords";
            hm.Content = "如何设置content = '大家好' ";
            hm.ID = "keywords";
            this.Page.Header.Controls.Add(hm);
      

  4.   

    Index.aspx 中的html代码:<%@ Page language="c#" Codebehind="Index.aspx.cs" AutoEventWireup="false" Inherits="test.Index" %>
    <%@ Register TagPrefix="uc1" TagName="me" Src="me.ascx" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <title>mete</title>
    <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
    <meta name="CODE_LANGUAGE" Content="C#">
    <meta name="vs_defaultClientScript" content="JavaScript">
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    <meta name="keywords" runat="server" id="keywords" content="改变前"/>
    </HEAD>
    <body MS_POSITIONING="GridLayout">
    <form id="Form1" method="post" runat="server">
    <FONT face="宋体">
    <uc1:me id="Me1" runat="server"></uc1:me></FONT>
    </form>
    </body>
    </HTML>
    用户控件me.ascx 的后台编码文件:public class me : System.Web.UI.UserControl
    { private void Page_Load(object sender, System.EventArgs e)
    {
    // 在此处放置用户代码以初始化页面 HtmlGenericControl keywords = this.Page.FindControl("keywords") as HtmlGenericControl;
    if(keywords!=null)
    {
    keywords.Attributes["content"] = "改变后^_^";
    }
    }楼主去试一下吧。
      

  5.   

    如果你的用户控件是直接放到当前页里的,而不是控件嵌套的话,有个语句还可以改为如下:HtmlGenericControl keywords = this.Parent.FindControl("keywords") as HtmlGenericControl;注意:这里的 Page 改为了 Parent