简体   繁体   中英

Overriding protected internal methods

I'm rewriting a web application to ASP.Net 4.0 and have included a Menu control (bound to a SiteMap file, naturally). While I'm liking the new RenderingMode property, I'm hating the fact that it automagically includes some javascript at the bottom of your page to animate the menu.

My preference would be for greater control using jQuery, but switching that off is proving very difficult. With some help from a very heavy hitter, I've been walked through to the point where I've discovered that the ASP.Net 4.0 Menu control has an internal OnPreRender method:

internal void OnPreRender(EventArgs e, bool registerScript);

How do I override this method so that I can call:

base.OnPreRender(e, false);

When trying at the moment, I'm getting an error from Visual Studio saying that "No overload for method 'OnPreRender' takes 2 arguments".

You should be able to refer to protected internal methods as they are protected or internal . If the method is just internal you might be out of luck.

Looking at ASP.NET 4 Menu control, it only has one OnPreRender override:

protected internal override void OnPreRender(EventArgs e);

So you should be able to override it. Not sure where OnPreRender(EventArgs e, bool registerScript) comes from (perhaps it's internal ), but the fact that the base class doesn't it(or it's inaccessible) is your problem.

这不是一个直接的答案,但是将任何IHeirarchicalDataSource的内容(例如站点地图文件)转储到<ul>相当简单,任何数量的jquery菜单产品都可以将其咀嚼并变成紫红色。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM