- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
1) 由于以下原因,我认为只能在 Page.PreInit 事件处理程序中以编程方式设置主题:
如果我们在 Page.Init 事件处理程序中设置一个主题,那么到那时 ViewState 已经被跟踪,因此主题应用的任何数据都将被跟踪并标记为脏(这会消耗大量带宽)?
如果我们在 Init 事件之后设置它,那么主题也可以覆盖应用于各个控件的反序列化 ViewState 数据?
Page.PreInit 后Themes 设置不上还有其他原因吗?
2)另外,为什么Page.PreInit之后不能应用Master pages?
谢谢
最佳答案
据此:
http://odetocode.com/articles/450.aspx
The 'MasterPageFile' property can only be set in or before the 'Page_PreInit' event.
This exception makes sense, because we know the master page has to rearrange the page’s control hierarchy before the Init event fires
文章还包括这个例子:
using System;
using System.Web.UI;
public class BasePage : Page
{
public BasePage()
{
this.PreInit += new EventHandler(BasePage_PreInit);
}
void BasePage_PreInit(object sender, EventArgs e)
{
MasterPageFile = "~/Master1.master";
}
}
或者,我以前用过的一种方法:
protected override void OnPreInit(EventArgs e)
{
base.OnPreInit(e);
if (Request.QueryString["Master"] == "Simple")
MasterPageFile = "~/Masterpages/Simple.Master";
}
关于c# - 为什么不能在 Page.PreInit 事件之后动态应用 Themes 和 Master pages?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1961950/
MSDN 说在页面生命周期的 PreInit 事件中创建动态控件。 http://msdn.microsoft.com/en-us/library/ms178472.aspx 为什么? 在 PreIn
我是 ASP.NET 新手。我有一个 aspx 页面,我必须在其 PreInit 事件中编写一些代码。从我在页面上找到 PreInit 事件的地方。当我们双击按钮来获取按钮单击事件(或选择按钮并从属性
目前在部署时我得到: Hook /opt/elasticbeanstalk/hooks/preinit/30directories.sh failed 我想完全使用 .ebextensions 删除
如何在 ASP.NET PreInit 事件中获取控制权?指针为 null,FindControl 方法返回 null。 我正在使用母版页和内容页。内容页面的标记如下所示: ..
目前在部署时我得到: Hook /opt/elasticbeanstalk/hooks/preinit/30directories.sh failed 我想完全使用 .ebextensions 删除
我的内容页面 default.aspx 中有以下标记: 在 PreInit 事件中访问标签时,显示的错误是 - 对象引用未设置为对象的实例 private void Page_PreInit
最近我使用了一个类,解释为 here在 PreInit 期间访问动态控件。该帖子的标题为“在 PreInit 期间访问 ASP.NET 页面控件”,在本地它运行完美,但在服务器上我收到以下错误: Co
以下是母版页与内容页合并时事件发生的顺序: Content page PreInit event. Master page controls Init event. Content controls
void Page_PreInit(Object sender, EventArgs e) { HttpCookie userInfo; userInfo = Request.Cook
1) 由于以下原因,我认为只能在 Page.PreInit 事件处理程序中以编程方式设置主题: 如果我们在 Page.Init 事件处理程序中设置一个主题,那么到那时 ViewState 已经被跟踪,
下面的代码工作正常。我可以在 _constructor 中编写扩展逻辑,并且扩展默认值将在所有表中被覆盖。 (function(window, document, undefined){ var fa
我是一名优秀的程序员,十分优秀!