p;
PortalModuleControl module = (PortalModuleControl) Page.LoadControl(_moduleConfiguration.DesktopSrc);
module.ModuleConfiguration = this.ModuleConfiguration;
module.PortalId = this.PortalId;
this.Controls.Add(module);
}
如果_cachedOutput为null,那么说明还没有缓存,于是调用base.CreateChildControls(),然后用LoadControl()方法重新(真实的)载入控件,并把这个控件放入本控件的子控件树中。
protected override void Render(HtmlTextWriter output) {
if (_moduleConfiguration.CacheTime == 0) {
base.Render(output);
return;
}
现在到了Render方法,这个方法用于输出控件的HTML,首先检查是否启用缓存,如果没有,直接调用base.Render()直接输出,然后return。
if (_cachedOutput == null) {
TextWriter tempWriter = new StringWriter();
base.Render(new HtmlTextWriter(tempWriter));
_cachedOutput = tempWriter.ToString();
Context.Cache.Insert(CacheKey, _cachedOutput, null, DateTime.Now.AddSeconds(_moduleConfiguration.CacheTime), TimeSpan.Zero);
}
如果启用了缓存,但是用来保存缓存内容的变量为null,那么就调用base.Render()方法,把所有应该输出的HTML输出到_cachedOutput变量中,然后把这个变量的内容放入Context.Cache中。
output.Write(_cachedOutput);
最后,把这个变量中的HTML内容输出。
作者:kaneboy Blog:http://blog.joycode.com/kaneboy/
PortalModuleControl module = (PortalModuleControl) Page.LoadControl(_moduleConfiguration.DesktopSrc);
module.ModuleConfiguration = this.ModuleConfiguration;
module.PortalId = this.PortalId;
this.Controls.Add(module);
}
如果_cachedOutput为null,那么说明还没有缓存,于是调用base.CreateChildControls(),然后用LoadControl()方法重新(真实的)载入控件,并把这个控件放入本控件的子控件树中。
protected override void Render(HtmlTextWriter output) {
if (_moduleConfiguration.CacheTime == 0) {
base.Render(output);
return;
}
现在到了Render方法,这个方法用于输出控件的HTML,首先检查是否启用缓存,如果没有,直接调用base.Render()直接输出,然后return。
if (_cachedOutput == null) {
TextWriter tempWriter = new StringWriter();
base.Render(new HtmlTextWriter(tempWriter));
_cachedOutput = tempWriter.ToString();
Context.Cache.Insert(CacheKey, _cachedOutput, null, DateTime.Now.AddSeconds(_moduleConfiguration.CacheTime), TimeSpan.Zero);
}
如果启用了缓存,但是用来保存缓存内容的变量为null,那么就调用base.Render()方法,把所有应该输出的HTML输出到_cachedOutput变量中,然后把这个变量的内容放入Context.Cache中。
output.Write(_cachedOutput);
最后,把这个变量中的HTML内容输出。
作者:kaneboy Blog:http://blog.joycode.com/kaneboy/
| 对此文章发表了评论 |

