主题
1、主题目录:App_Themes
2、没有定义skinid的主题为默认主题
3、一键切换主题
3.1 主题切换只能在Page_PreInit事件中
3.2 Response.Redirect("formview.aspx?t=red") //重定向到本页,带变量t
4、添加CSS样式
2、没有定义skinid的主题为默认主题
3、一键切换主题
3.1 主题切换只能在Page_PreInit事件中
3.2 Response.Redirect("formview.aspx?t=red") //重定向到本页,带变量t
protected void Page_PreInit(object sender, EventArgs e)
{
if (Request.QueryString["t"] != null)
{
Page.Theme = Request.QueryString["t"].ToString();
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("Themes.aspx?t=red");
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Redirect("Themes.aspx?t=blue");
}
{
if (Request.QueryString["t"] != null)
{
Page.Theme = Request.QueryString["t"].ToString();
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("Themes.aspx?t=red");
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Redirect("Themes.aspx?t=blue");
}
4、添加CSS样式
protected void Page_Load(object sender, EventArgs e)
{
Style CustomStyle = new Style();
CustomStyle.Font.Name = "方正姚体";
CustomStyle.Font.Size = new FontUnit(24);
CustomStyle.ForeColor = System.Drawing.ColorTranslator.FromHtml("#f00");
Label1.ApplyStyle(CustomStyle);
}
PS:实例化样式对象,并设置属性,并添加到控件上去。{
Style CustomStyle = new Style();
CustomStyle.Font.Name = "方正姚体";
CustomStyle.Font.Size = new FontUnit(24);
CustomStyle.ForeColor = System.Drawing.ColorTranslator.FromHtml("#f00");
Label1.ApplyStyle(CustomStyle);
}