Custom control error: 'Type "xxx" cannot be resolved'
I wanted to be able to limit the categories that the Category widget displays (by default all of them) and I found this -
, which sounded good. So I took this code and followed the instructions from here - (I changed the name of the namespace to SubCategoryWidget and the name of the code file to SubCategory), and then here -However, when I drag the newly created control onto a page I get the error 'Type "SubCategoryWidget.SubCategory" cannot be resolved''. The cause seems fairly obvious in that the control cannot be found, so I tried changing the ControlType to ~/SubCategoryWidget.SubCategory; /SubCategoryWidget.SubCategory and other variations without success.
I still think it's probably a simple thing that's causing the problem, but I can't see what it is. Can anyone help?
BTW, Our site is using VB.NET, so I have converted the C# code.
Cheers.
Got there in the end. When registering the control, in the Control CLR Type or Virtual Path field the format needed to be ProjectName.NameSpace.CodeFileName
Can you give a concrete example?
I have web-project named SitefinityWebApp. I added CustomWidgets/LibrarySelector and then added file MyLibrarySelector.ascx. The .cs shows namespace to be SitefinityWebApp.LibrarySelector.
I tried following combinations:
~/Sitefinity/CustomWidgets/LibrarySelector/SitefinityWebApp.SitefinityWebApp.LibrarySelector.MyLibrarySelector.ascx
~/CustomWidgets/LibrarySelector/SitefinityWebApp.SitefinityWebApp.LibrarySelector.MyLibrarySelector.ascx
~/SitefinityWebApp.SitefinityWebApp.LibrarySelector.MyLibrarySelector.ascx
~/SitefinityWebApp.LibrarySelector.MyLibrarySelector.ascx
SitefinityWebApp.SitefinityWebApp.LibrarySelector.MyLibrarySelector.ascx
SitefinityWebApp.LibrarySelector.MyLibrarySelector.ascx
And all of the above without namespace before I got to this thread.
Thanks.
Hi Shriyal,
I've only just seen your question so this is probably way too late.
I just created a class, not a user control, so as you're using an ascx file you just need to add in the path to that file e.g. ~/CustomWidgets/LibrarySelector/MyLibrarySelector.ascx.