如何在page_preinit事件中使用主题 [英] How to use theme in page_preinit event

查看:158
本文介绍了如何在page_preinit事件中使用主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在页面中使用了多个主题.从下拉菜单中进行选择时,所选主题应应用于整个页面.从下拉菜单中选择项目时,显示错误消息"Theme属性只能在Page_PreInit事件中或之前设置".如何解决这个问题...

Im using multiple themes in my page. When choosing from dropdown,selected theme should be applied to whole page. While choosing the item from dropdown,im getting error as ''The Theme property can only be set in or before Page_PreInit Event''. How to solve this...

推荐答案

尝试一下
protected void Page_PreInit(object sender, EventArgs e)
{
    if (IsPostBack)
    {
        Page.Theme = DropDown1.SelectedValue;
    }
  else
    {
      Page.Theme  = //defaule theme name 
    }
}


使用此链接作为参考
http://msdn.microsoft.com/en-us/library/tx35bd89.aspx


Use this link for reference
http://msdn.microsoft.com/en-us/library/tx35bd89.aspx



Page_PreInit在页面lyfecycle中仅被调用一次.您不能将其用于IsPostBack.而不是尝试此操作并输入条件:
Hi,
Page_PreInit get called only once in page lyfecycle. You cannot use that for IsPostBack. Instead of that try this and put the conditions:
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        Page.Theme = DropDown1.SelectedValue;
    }
  else
    {
      Page.Theme  = //other themes name
    }
}




--Amit




--Amit


这篇关于如何在page_preinit事件中使用主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆