How to fix the problem with new layout of the custom web part

In this article is shown how to correctly create new layout for your custom web part on the Layout tab.
If you want to create a new layout of the custom web part, you may sometimes encounter similar error:

http://server/KenticoCMS/CMSWebPartLayouts/<GUID>/myWebpart.ascx.cs(912305): error CS0115: 'ASP.cmswebpartlayouts_<GUID>_myWebpart___custom_ascx.FrameworkInitialize()': no suitable method found to override

You may need to set the relative path to the code behind file in the layout. Please find an example below.

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="~/CMSWebParts/_custom/custom.ascx.cs" Inherits="CMSWebParts__custom_custom" %>

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="custom.ascx.cs" Inherits="CMSWebParts__custom_custom" %>

See also:

Applies to: Kentico CMS 4.1 and all higher versions
Share this article on   LinkedIn

Juraj Ondrus

Hi, I am the Technical support leader at Kentico. I'm here to help you use Kentico and get as much as possible out of it.