ASPX templates
Version 5.x > ASPX templates > Trying to create my first web part ([Error loading the WebPart '...'] ) View modes: 
User avatar
Member
Member
lars.kvanum-viasat - 3/8/2010 3:49:39 AM
   
Trying to create my first web part ([Error loading the WebPart '...'] )
Hi,

I wanted to create my first web part today - something simple to get me going. However, I'm getting the above error in a red frame (accompanied by "Could not load type 'CMSWebParts_ViasatCustom_SearchCampaignsCS'".

SearchCampaignsCS.cs.ascx:

What I've done is create an ascx in /CMSWebParts/ViasatCustom.

My sources are as follows:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CMS.PortalControls;

public partial class CMSWebParts_ViasatCustom_SearchCampaignsCS : CMSAbstractWebPart
{
protected void Page_Load(object sender, EventArgs e)
{

}
}

SearchCampaignsCS.ascx:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SearchCampaignsCS.ascx.cs" Inherits="CMSWebParts_ViasatCustom_SearchCampaignsCS" %>
<asp:Panel ID="Panel1" runat="server">
<asp:TextBox ID="txtKampanjeKodeSoek" runat="server"></asp:TextBox>
 
<a href="javascript:window.location='Kampanjedetaljer.aspx?Kode=' + document.getElementById('ctl00_main_txtKampanjeKodeSoek').value;">Hent kampanje</a>
</asp:Panel>
</asp:Panel>

Could someone please help me out here? I've got a whoping 10 minutes experience with this product and would love to get a push in the right direction. Cheers!

User avatar
Member
Member
lars.kvanum-viasat - 3/8/2010 4:57:01 AM
   
RE:Trying to create my first web part ([Error loading the WebPart '...'] )
Never mind - got it sorted :)

User avatar
Member
Member
kevin.clark-gaprc - 3/21/2011 10:55:25 AM
   
RE:Trying to create my first web part ([Error loading the WebPart '...'] )
I know it's been a while since you had this problem, but would you mind sharing what you did to fix your issue. I'm having the same problem and for the life of me I can't figure out what I'm doing wrong.

Thanks

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 3/22/2011 5:19:41 AM
   
RE:Trying to create my first web part ([Error loading the WebPart '...'] )
Hi,

could you please check if the path to the physical file is defined correctly in the webpart registration section in the Site Manager - Development - Web parts - some webpart - General tab - File name.

If it does not help, could you please go through the tutorial again and check if you set everything correctly?
http://devnet.kentico.com/docs/devguide/developing_web_parts.htm?zoom_highlightsub=create%2Bwebpart

Alternatively, you could clone one of the existing webparts (Site Manager - Development - Webparts - Clone webpart) and replace the class content with your code.

Best regards,
Ivana Tomanickova

User avatar
Member
Member
kevin.clark-gaprc - 3/22/2011 6:10:53 AM
   
RE:Trying to create my first web part ([Error loading the WebPart '...'] )
Ivana,

Thanks for your response, but it seems that when registering a user control Kentico adds a "~" to the begining of the path when you browse to the control. Once I removed the "~" my problem was resolved. Also, if I import user controls I created outside of the Kentico web project the control doesn't work and I get the error posted above. However, if I create a new control inside of the Kentico we project and then paste in all my code from my other control into it, it works just fine!

Kevin

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 3/22/2011 8:09:48 AM
   
RE:Trying to create my first web part ([Error loading the WebPart '...'] )
Hi,

Could you please tell me, which version (hotfix) of Kentico CMS you are using? I would like to reproduce the "~" issue.

Thank you,
Ivana Tomanickova

User avatar
Member
Member
kevin.clark-gaprc - 3/22/2011 8:20:07 AM
   
RE:Trying to create my first web part ([Error loading the WebPart '...'] )
The version listed is v5.5.3789 also, Radek Macalik, one of your support devlopers reproduced this in my environment and was the one who instructed me to remove the "~" from the path.

Thanks

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 3/23/2011 3:57:09 AM
   
RE:Trying to create my first web part ([Error loading the WebPart '...'] )
Hi,

this is detail information for other forum readers:

It is better to develop custom user controls inside the Kentico project. Alternatively, you could use the User Control webpart to add your external ascx user control to the page.

Best regards,
Ivana Tomanickova