简体   繁体   English

在菜单控件中重写渲染方法的正确方法是什么

[英]What is the correct way of overriding render method in Menu control

I did perform investigation and I didn't find good and constructive information to my questions. 我确实进行了调查,但没有发现对我的问题有帮助的有益信息。 That is why my question is regarding the control which I would like to extend and render the controls on my own way.I'm working with SharePoint but the SharePoint aspnet control is sealed so I cannot derive from it. 这就是为什么我的问题是关于我想以自己的方式扩展和呈现控件的控件。我正在使用SharePoint,但是SharePoint aspnet控件是密封的,所以我不能从中派生。

What I have is a menu control which derives from: System.Web.UI.WebControls.Menu or Microsoft.SharePoint.WebControls.AspMenu I don't see any big difference. 我有一个菜单控件,该控件派生自:System.Web.UI.WebControls.Menu或Microsoft.SharePoint.WebControls.AspMenu我看不出有什么大不同。 And I have the data source / data provider. 而且我有数据源/数据提供者。

SiteMapDataSource dataSource = this.GetDataSource() as SiteMapDataSource;
SiteMapProvider provider = dataSource.Provider;

So I have all the needed elements. 所以我拥有所有需要的元素。

Now the base classe has a lot of different methods which I can override, but I'm not sure how to start with. 现在,基类具有许多可以重写的不同方法,但是我不确定如何开始。

Where and how should I create controls to render? 我应该在哪里以及如何创建控件以进行渲染? Where do I render those controls? 我在哪里渲染这些控件? The contols they exist of html? 它们存在于HTML中吗?

<ul>
 <li> </li>
 ...
</ul>

How do I build then a menu based on the provider? 然后如何基于提供者构建菜单?

Just a small update to give a full picture: I do this because I need to render first control not as a link and text but as a image link with image set to a provided url. 进行一次小小的更新就可以得到完整的图片:之所以这样做,是因为我需要将第一个控件而不是链接和文本呈现,而是将图像设置为提供的URL的图像链接。

Hello you can use extension method on Menu 您好,您可以在菜单上使用扩展方法

public static void YourExtension(this Menu control)
{
     control.YourPropertyTarget = ....;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 制作控制台菜单的“正确”方法是什么? - What is the “correct” way of making a console menu? 创建自定义控件的正确方法是什么 - What's the correct way to create a custom control 用自定义TextWriter覆盖Render方法 - Overriding the Render method with a custom TextWriter 调用 Polly ExecuteAsync 方法的正确方法是什么? - What is the correct way to call Polly ExecuteAsync method? 异步运行同步方法的正确方法是什么 - What is the correct way to run synchronous method in asynchronously 调用扩展方法(TreeNodeCollection Add 方法)的正确方法是什么? - What is the correct way to call an extension method (TreeNodeCollection Add method)? 在另一个方法中创建的方法中停止对象的正确方法是什么? - What is the correct way of stopping an object in a method that was created in another? 从方法返回接口类型的正确方法是什么? - What is the correct way to return an Interface Type from a Method? 在递归方法中使用 async/await 的正确方法是什么? - What is the correct way to use async/await in a recursive method? 在列表中的每个项目上调用.ToString()方法的正确方法是什么? - What is the correct way to call the .ToString() method on each item in a list?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM