Kentico CMS provides various built-in web parts. We can also have our custom web parts and use them within our pages as this flexibility is provided by Kentico CMS system.
Below steps are to be followed to create and use a new custom web parts using Kentico CMS.
1) Open the WebProject solution created at the time of installing Kentico.
2) Within the folder ‘CMSWebParts’ create a new folder lets say ‘CustomWebParts’.
3) Create a new UserControl(ascx file) with required functionality within this folder(Let the name is Timer.ascx).
4) Add the following line to the beginning of the code:
Example in C# :-
using
CMS.PortalControls;
5) In the ascx file we have to change the following lines:-
public partial class CMSWebParts_CustomWebParts_Timer: System.Web.UI.UserControl public partial class CMSWebParts_CustomWebParts_Timer: CMSAbstractWebPart to public partial class CMSWebParts_CustomWebParts_Timer: CMSAbstractWebPart
6) Then go to the location ‘SiteManager>>WebParts’ click on the root and create a new category(Lets say the name is ‘MyCategory’).
7) Under this category create new web part and provide the following details :-
. Web part display name: Timer
. Web part code name: Timer
. Web part file name: CustomWebParts/Timer.ascx
8) Now our custom web part is ready for use in the page by being adding with a web-part zone.
> Add a web-part zone to the page like below code :-
Ex - <cc1:CMSWebPartZone ID="zoneTopRight" runat="server" />
> Then design of the page we can find a ‘Add webpart button ‘ at the right corner of the web-part zone.
> Add the web part by clicking the ‘add web-part’ button and choosing the custom webpart from the list of web-parts.
Now the functionality of the custom web-part can be used in the particular page.