Creating a webpart

Ilse VDH asked on April 16, 2014 04:54

Hello

I'm new to Kentico and i'm struggling to create a custom web part :-(

I tried doing this by the developing tutorial and create the 'hello world' web part in visual studio. Then i copied the code files(HelloWorld.ascx, HellowWorld.ascx.cs and HelloWorld.ascx.designet.cs) through ftp in the '\CMSWebParts' folder. Then i went to my sitemanager -> development -> create a new category -> create a new web element and i choose the file name through the select option:

Image Text

Then i go to the cms desk and try to add the new web part to a page, but when the web part is added i receive a Could not load type 'CMSApp.CMSWebParts.Infomat2.HelloWorld' error.

Image Text

Recent Answers


Brenden Kehren answered on April 16, 2014 06:37

Check in the Event log for more information. It sounds as if you might be using the Web Project vs. a Web Site, is that correct? If so you will need to recompile your website and then deploy it.

1 votesVote for this answer Mark as a Correct answer

Vilém Jeniš answered on April 16, 2014 06:37

Hi Ilse!

Could you, please, provide the information in the event log related to this error?

Usually when a similar error occurs it's due to an unhadled exception thrown while loading the webpart. The exception along with all relevant information shoud be in the event log. The event is reproduced every time you reload the page.

.

Best regards,

Vilém Jeniš

Kentico developer

0 votesVote for this answer Mark as a Correct answer

Ilse VDH answered on April 16, 2014 07:51

The website is already running and my visual studio project is not connected to that location. What i actually want is to make a small change to an existing web part and i thought i could simple change that code and reupload it.

If I build the visual studio project on my local computer, what do i need to do to have my changes/new web parts visible?

And here is the event log:

ID de l'événement: 13202
Type d'événement: Erreur
Heure de l'événement: 4/16/2014 2:41:47 PM
Source: PortalEngine
Code de l'événement: LOADWEBPART
Nom de l'utilisateur: administrator
Adresse IP: 81.82.231.100

Description: Message: Could not load type 'CMSApp.CMSWebParts.Infomat2.HelloWorld'. Stack Trace: at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding) at System.Web.UI.TemplateParser.ParseReader(StreamReader reader, VirtualPath virtualPath) at System.Web.UI.TemplateParser.ParseFile(String physicalPath, VirtualPath virtualPath) at System.Web.UI.TemplateParser.ParseInternal() at System.Web.UI.TemplateParser.Parse() at System.Web.UI.TemplateParser.Parse(ICollection referencedAssemblies, VirtualPath virtualPath) at System.Web.Compilation.BaseTemplateBuildProvider.get_CodeCompilerType() at System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(BuildProvider buildProvider) at System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders() at System.Web.Compilation.BuildProvidersCompiler.PerformBuild() at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.UI.TemplateControl.LoadControl(VirtualPath virtualPath) at System.Web.UI.TemplateControl.LoadControl(String virtualPath) at CMS.PortalControls.CMSWebPartZone.LoadWebPart(Control container, CMSWebPartZone zone, WebPartInstance part, Boolean reloadData, Boolean isVariant) at System.Web.UI.TemplateParser.ProcessException(Exception ex) at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding) at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding) at System.Web.UI.TemplateParser.GetType(String typeName, Boolean ignoreCase, Boolean throwOnError) at System.Web.UI.TemplateParser.ProcessInheritsAttribute(String baseTypeName, String codeFileBaseTypeName, String src, Assembly assembly) at System.Web.UI.TemplateParser.PostProcessMainDirectiveAttributes(IDictionary parseData)

Nom de la machine: SRV-WEB-01-FLF
URL de l'événement: /cms/getdoc/8529e065-da52-4b7a-afc5-0ed2a9f8649d/Liens.aspx
Le référant de l'URL: http://www.flf.lu/CMSModules/Content/CMSDesk/Edit/editpage.aspx?nodeid=303&mode=design
L'agent de l'utilisateur: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on April 16, 2014 08:01 (last edited on April 16, 2014 08:01)

You might look into the difference between a web site and a web project within Visual Studio, this would help you to understand the differences.

Regarding getting it to work, build your website locally and redeploy the DLL that is created in the bin directory and redeploy the .ascx file for that webpart. There will most likely only be one DLL created/updated, so sort by create/modified time in file explorer to ensure you get the right one as you don't need to redeploy all DLLs.

1 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on April 16, 2014 08:01 (last edited on April 16, 2014 08:01)

I should also mention you might want to make backups of your project and your website as well, just in case...

0 votesVote for this answer Mark as a Correct answer

James Harrison answered on January 23, 2015 17:05

We had the same issue and found a fix for it. The issue was that when Kentico was generating the code files, it ( when first creating the web part) it incorrectly put in:

Codebehind="~/App_Data/CodeTemplates/WebPart.ascx.cs"

in the "<%@ Control..." tag of the ascx file instead of

Codefile="NameOfYourWebPart.ascx.cs"

we updated it from "codebehind" to "codefile" and entered the correct file name and the issue was fixed

I hope this helps someone else with the same issue

James

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.