在 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 = '大家好' "/>
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 = '大家好' "/>
hm.Name = "keywords";
hm.Content = "如何设置content = '大家好' ";
hm.ID = "keywords";
this.Page.Header.Controls.Add(hm);
<%@ 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"] = "改变后^_^";
}
}楼主去试一下吧。