首页上一页 1 下一页尾页 1 条记录 1/1页
《ASP.NET从入门到精通》(第二版)第7章 7.3.2动态加载主题的问题
发表在ASP.NET图书答疑
2014-02-07
是否精华
是
否
版块置顶:
是
否
原书的例子不错,我手痒,在母板页的内容页仿照这个例子,设置Page.StyleSheetTheme。结果总是失败。
主要代码如下:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
//string url = Request.Path + "?theme=" + DropDownList1.SelectedItem.Value;
string url = Request.Path + "?StyleSheetTheme=" + DropDownList1.SelectedItem.Value;
Response.Redirect(url);
}
void Page_PreInit(Object sender, EventArgs e)
{
string theme = "Default";
//if (Request.QueryString["theme"] == null)
if (Request.QueryString["StyleSheetTheme"] == null)
{
theme = "Default";
}
else
{
//theme = Request.QueryString["theme"];
theme = Request.QueryString["StyleSheetTheme"];
}
//Page.Theme = theme;
Page.StyleSheetTheme = theme;
ListItem item = DropDownList1.Items.FindByValue(theme);
if (item != null)
{
item.Selected = true;
}
}
结果总是出错。上百度那里瞄了好久也没答案。
这个应该不属于原书的问题,不过,如果你们有兴趣,能否给个答案?
谢谢!
主要代码如下:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
//string url = Request.Path + "?theme=" + DropDownList1.SelectedItem.Value;
string url = Request.Path + "?StyleSheetTheme=" + DropDownList1.SelectedItem.Value;
Response.Redirect(url);
}
void Page_PreInit(Object sender, EventArgs e)
{
string theme = "Default";
//if (Request.QueryString["theme"] == null)
if (Request.QueryString["StyleSheetTheme"] == null)
{
theme = "Default";
}
else
{
//theme = Request.QueryString["theme"];
theme = Request.QueryString["StyleSheetTheme"];
}
//Page.Theme = theme;
Page.StyleSheetTheme = theme;
ListItem item = DropDownList1.Items.FindByValue(theme);
if (item != null)
{
item.Selected = true;
}
}
结果总是出错。上百度那里瞄了好久也没答案。
这个应该不属于原书的问题,不过,如果你们有兴趣,能否给个答案?
谢谢!