Error loading the WebPart, Custom WebPart not Loading

Mike Bilz asked on November 20, 2020 21:06

Hello Kentico Team,

I have received the dreaded [Error loading the WebPart 'ContactInformation' of type 'ContactInfo'] error. No information about this error appears in the Event Log, and no further information is provided anywhere else about what precisely the issue is.

I built this WebPart by copying an existing custom WebPart and adding new fields and content.

ASCX:


<%@ Control Language="C#" AutoEventWireup="true" Inherits="CMSWebParts_LACC_ContactInfo"  CodeFile="~/CMSWebParts/LACC/ContactInfo.ascx.cs" %>
<div class="pageWidth">
    <div class="contactInfoHolder clearfix">
        <div class="contactInfoItem oneFifthWidth">
            <asp:Panel ID="MeetingButton" runat="server" class="contactInfoLink"><asp:HyperLink ID="MeetingLink" Target="_blank" ToolTip="Schedule a Meeting" runat="server"/></asp:Panel>
        </div>
        <div class="contactInfoItem oneFifthWidth">
            <asp:Panel ID="LiveChatButton" runat="server" class="contactInfoLink"><asp:HyperLink ID="LiveChatLink" Target="_blank" ToolTip="Live Chat and Support" runat="server"/></asp:Panel>
        </div>
        <div class="contactInfoItem oneFifthWidth">
            <asp:Panel ID="EmailButton" runat="server" class="contactInfoLink"><asp:HyperLink ID="EmailLink" Target="_blank" ToolTip="Email this Department" runat="server"/></asp:Panel>
        </div>
        <div class="contactInfoItem oneFifthWidth">
            <asp:Panel ID="LobbyButton" runat="server" class="contactInfoLink"><asp:HyperLink ID="LobbyLink" Target="_blank" ToolTip="Drop-in Lobby" runat="server"/></asp:Panel>
        </div>
        <div class="contactInfoItem oneFifthWidth">
            <asp:Panel ID="LobbyText" runat="server" class="contactInfoText"><asp:Literal ID="LobbyHours" runat="server"/></asp:Panel>
        </div>

    </div>
    <asp:HyperLink ID="WebsiteLink" Target="_blank" runat="server" CssClass="redButton zButton"/>

ASCX.CS:


using System;
using System.Data;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using CMS.PortalControls;
using CMS.Helpers;

public partial class CMSWebParts_LACC_ContactInfo : CMSAbstractWebPart
{
    #region "Properties"

    public string DepartmentNameVar
    {
        get
        {
            return ValidationHelper.GetString(this.GetValue("DepartmentName"), "");
        }
        set
        {
            this.SetValue("DepartmentName", "");
        }
    }
    public string MeetingLinkVar
    {
        get
        {
            return ValidationHelper.GetString(this.GetValue("MeetingLink"), "");
        }
        set
        {
            this.SetValue("MeetingLink", "");
        }
    }
    public string LiveChatLinkVar
    {
        get
        {
            return ValidationHelper.GetString(this.GetValue("LiveChatLink"), "");
        }
        set
        {
            this.SetValue("LiveChatLink", "");
        }
    }
    public string EmailLinkVar
    {
        get
        {
            return ValidationHelper.GetString(this.GetValue("EmailLink"), "");
        }
        set
        {
            this.SetValue("EmailLink", "");
        }
    }
    public string LobbyLinkVar
    {
        get
        {
            return ValidationHelper.GetString(this.GetValue("LobbyLink"), "");
        }
        set
        {
            this.SetValue("LobbyLink", "");
        }
    }
    public string LobbyHoursVar
    {
        get
        {
            return ValidationHelper.GetString(this.GetValue("LobbyHours"), "");
        }
        set
        {
            this.SetValue("LobbyHours", "");
        }
    }
    public string WebsiteLinkVar
    {
        get
        {
            return ValidationHelper.GetString(this.GetValue("WebsiteLink"), "");
        }
        set
        {
            this.SetValue("WebsiteLink", "");
        }
    }


    #endregion


    #region "Methods"

    /// <summary>
    /// Content loaded event handler.
    /// </summary>
    public override void OnContentLoaded()
    {
        base.OnContentLoaded();
        SetupControl();
    }


    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (this.StopProcessing)
        {
            // Do not process
        }
        else
        {
            MeetingLink.NavigateUrl = MeetingLinkVar;
            MeetingLink.Text = "Schedule a Meeting with " + DepartmentName + "";
            LiveChatLink.NavigateUrl = LiveChatLinkVar;
            LiveChatLink.Text = "Live Chat with " + DepartmentName + "";
            EmailLink.NavigateUrl = "mailto: " + EmailLinkVar + "";
            EmailLink.Text = "Email " + DepartmentName + "";
            LobbyLink.NavigateUrl = LobbyLinkVar;
            LobbyLink.Text = "Visit the " + DepartmentName + "Drop-In Lobby";
            LobbyHours.Text = LobbyHoursVar;
            WebsiteLink.NavigateUrl = WebsiteLinkVar;
            WebsiteLink.Text = "Visit the " + DepartmentName + " Website";
        }
    }


    /// <summary>
    /// Reloads the control data.
    /// </summary>
    public override void ReloadData()
    {
        base.ReloadData();

        SetupControl();
    }

    #endregion
}

Any assistance would be greatly appreciated.

Thanks. -mike

Recent Answers


David te Kloese answered on November 20, 2020 21:14

How did you copy the Web Part? From the Admin interface or manually?

Can you confirm the code behind reference is correct:

<%@ Control Language="C#" AutoEventWireup="true" Inherits="CMSWebParts_LACC_ContactInfo" CodeFile="~/CMSWebParts/LACC/ContactInfo.ascx.cs" %>

Could it be it references the OLD code file instead of your new one?

0 votesVote for this answer Mark as a Correct answer

Mike Bilz answered on November 20, 2020 21:29

Hi David,

The code files were manually copied and edited before uploading to the site, then the custom WordPart was created in Kentico linking to the new files.

The file names are ContactInfo.ascx and ContactInfo.ascx.cs and the files are in the appropriate folder.

Thanks. -mike

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on November 20, 2020 21:30

No sure what version you're on but in v11 and 12 I believe you need a using statement for the CMS.PortalEngine.Web.UI dll.

0 votesVote for this answer Mark as a Correct answer

Mike Bilz answered on November 20, 2020 23:48

Hi Brenden,

I am using version v10.0.26, and none of my other custom WebParts have the PortalEngine call.

This is extremely perplexing because the code behind file is identical to all of my other custom WebParts, and yet this one is throwing an error.

Could this be as simple as a syntax error? Or maybe a step I missed on the Portal Engine side?

Thanks.

-mike

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on November 21, 2020 03:54 (last edited on November 23, 2020 16:29)

If you're using a web app you'll need to build it and redeploy that dll. If you're using a website you can just deploy that .cs file.

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on November 23, 2020 10:35 (last edited on November 23, 2020 20:35)

Could you please double-check the version you are using? I am asking because the CMS.PortalControls was removed in Kentico 10 and replaced by CMS.PortalEngine.Web.UI - so, in Kentico 10 you should be using it. Also, the CMSAbstractWebPart class is part of the new namespace. Are you able to build the code in Visual studio with no errors? I just copied your code (I just changed the file name and replaced CMS.PortalControls with CMS.PortalEngine.Web.UI) and it is working fine. I am getting the list if links (sample screen shot) and no errors.

0 votesVote for this answer Mark as a Correct answer

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