HtmlHead类动态添加<head>中子标签,如<title>和<style>,尤其是后者,就是动态配置CSS。例子如下:
protected void Page_Load(object sender, EventArgs e)
{
Style bodyStyle = new Style();
bodyStyle.ForeColor = System.Drawing.Color.Red;
bodyStyle.BackColor = System.Drawing.Color.Black;
Page.Header.StyleSheet.CreateStyleRule(bodyStyle, null, "BODY");
Page.Header.Title = "这里写Title";
}
{
Style bodyStyle = new Style();
bodyStyle.ForeColor = System.Drawing.Color.Red;
bodyStyle.BackColor = System.Drawing.Color.Black;
Page.Header.StyleSheet.CreateStyleRule(bodyStyle, null, "BODY");
Page.Header.Title = "这里写Title";
}
HtmlMeta类负责动态增加Meta标签,一般用不到,反正我是不用,代码示例如下:
protected void Page_Load(object sender, EventArgs e)
{
HtmlMeta meta = new HtmlMeta();
meta.Name = "";
meta.Content = "";
HtmlHead head = (HtmlHead)Page.Header;
head.Controls.Add(meta);
}
{
HtmlMeta meta = new HtmlMeta();
meta.Name = "";
meta.Content = "";
HtmlHead head = (HtmlHead)Page.Header;
head.Controls.Add(meta);
}