我在用户控件的代码后面。我需要访问页面的属性之一(EnableSessionState
)。
最初,这将在aspx中定义如下:
<%@ Page Language="C#" EnableSessionState="ReadOnly" %>
但是,我想在后面的代码中动态更改此值。
我看着这个答案:
PagesSection pages = WebConfigurationManager.OpenWebConfiguration("").GetSection("system.web/pages") as PagesSection;
pages.EnableSessionState = PagesEnableSessionState.ReadOnly;
不幸的是,我只是试图读取标题。还考虑了这个答案:
PagesSection pagesSection = new PagesSection();
pagesSection.EnableSessionState = PagesEnableSessionState.ReadOnly;
但是我不是在尝试读取默认值,而是在设置实际页面的值。
不幸的是,没有像this.Page.PagesSection
这样的属性,那么还有另一种解决方法吗?
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句