【发布时间】:2017-10-13 03:09:42
【问题描述】:
我正在尝试使用部分类覆盖 OnPreRender 事件
第一类来自 Kentico CMS,我无法更改这些类,因为它是 CMS 中的默认类。现在我想在第二个类中覆盖第一个类中 OnPreRender 事件的默认行为,第二个类是我手动创建的自定义类。
第一类
using System;
using System.Collections.Generic;
using CMS.UIControls;
using CMS.ExtendedControls;
using CMS.PortalEngine;
using CMS.Helpers;
public partial class CMSPages_PortalTemplate : PortalPage
{
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
// Init the header tags
//tags is a label
tags.Text = HeaderTags;
if (PortalContext.ViewMode.IsWireframe())
{
CSSHelper.RegisterWireframesMode(this);
}
}
}
2 级
using CMS.UIControls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
public partial class CMSPages_PortalTemplate : PortalPage
{
public CMSPages_PortalTemplate()
{
}
protected override void OnPreRender(EventArgs e)
{
//Override behavior
tags.Text = tags.Text + HeaderTags + "MyTest";
}
}
这可能吗?我试过调试,但它从来没有命中第二类的 OnPreRender 事件
【问题讨论】:
标签: c# asp.net c#-4.0 kentico asp.net-4.5