I'm little confused with the creation of a custom WebControl for a CustomAction.
I was following this tutorial : https://weblogs.asp.net/jan/creating-hierarchical-menus-with-a-customaction-in-sharepoint, but in my case nothing happens.
I guess it is because I don't how to create the class which inherits from WebControl. How do I have to create this class? I have to click on "Add a item", then "User Control (Farm Solution only"? Or I have to click just on "Class" classic? But for the last solution, how can I add this class to my assembly?
Here the code :
Elements.xml
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="Essai"
Location="Microsoft.SharePoint.StandardMenu"
GroupId="SiteActions"
ControlAssembly="XXX"
ControlClass="XXX.Web.CustomisationSiteActions">
</CustomAction>
</Elements>
In CustomisationSiteActions.cs :
using Microsoft.SharePoint.WebControls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI.WebControls;
namespace XXX.Web
{
public class CustomisationSiteActions : WebControl
{
// Add a the new "lol" menu item
protected override void CreateChildControls()
{
MenuItemTemplate item = new MenuItemTemplate();
item.Text = "lol";
item.Description = "lol";
item.Sequence = 2005;
this.Controls.Add(item);
}
}
}
Thanks for your help.