Type not defined when using skins in a custom control RRS feed

  • Question

  • User1533001300 posted

    I have created a custom control which in puts a graphical box around controls which is contained in the control.
    This means that I can group controls and then put a box around it (like a panel but with a pretty box around it) eg below:

    <MyProjectUI:CollaspsingPanel runat="server" skinid="Blue" HeaderText="Header1">
    <asp:Label ID="Label2" runat="server" Text="Label" Font-Bold="true"></asp:Label>
    <asp:Label ID="Label3" runat="server" Text="Label" Font-Bold="true"></asp:Label>
    <asp:Label ID="Label4" runat="server" Text="Label" Font-Bold="false"></asp:Label>
    <asp:Label ID="Label5" runat="server" Text="Label" Font-Bold="true"></asp:Label>

    This is inherited from the panel control and to achieve this I have referred to a stylesheet to say where the images are which I want to store in the App_theme folder so that I can create different themes and skins (different boxes to put around the containing panel)

    When I create a skin file with my control

    <%@ Register Assembly="MyProject.Portal" Namespace="MyProject.Portal.UI" TagPrefix="MyProjectUI" %>
    <MyProjectUI:CollaspsingPanel runat="server" skinid="Blue" HeaderText="Header1">

     and try and run my project it comes up with

     BC30002: Type 'MyProject.Portal.UI.CollaspsingPanel' is not defined.


    If anyone can give me some guidence on skinning a custom control I would be very appreciative

    Monday, October 9, 2006 12:40 PM

All replies

  • User-1146798798 posted

    I've got exactly the same issue.

    Any solution yet?


    Saturday, November 11, 2006 9:08 AM
  • User1533001300 posted

    It the moment this problem has taken a bit of a back burner...

    I think it has something to do with the namespace of my Class library and all is getting confused.

    If you find out please share the knowledge [:)]

    Saturday, November 11, 2006 10:28 AM
  • User1416329745 posted

    I think I have an idea of your problem because you are inheriting from the Panel Asp.net does not know what you are doing. What I mean is the Panel is in Page_Load event while Skins are defined in PreInit so Asp.net does not know what you are doing because it is too far down the pipeline.  The links below will take you in the right direction, the first shows a similar problem, then Codeproject Skin tutorial showing the events pipeline.  Hope this helps.




    Saturday, November 11, 2006 1:01 PM
  • User1533001300 posted

    Hi Caddre

    I have solved this problem today and it has nothing to do with the inheritance from the panel.

    I actually managed to have the same code in the app_code working but when I put it in a class library it showed this error : BC30002: Type 'MyProject.Portal.UI.CollaspsingPanel' is not defined.


    The problem was because the name that I used for the class library (MyProject.Portal) clashed with the name of the theme folder which was MyProject.

    Interesting problem here. This is what I think....

    So what happens is at run time the compiler creates a class called MyProject which it deals with the theme and collecting the information for the skins (css files, skin names etc all done in the background). I think it does alll this at the pre int stage in the page life cycle and because this class is called MyProject the compiler seems to get confused thinking that the run time class is the class library.

    If people are having problems with a similar error try changing the theme folder name in the AppThemes folder. As soon as I changed that it all worked ok, just like it did when the class was in the App_Code.

     Thanks for you feedback though

    Saturday, November 11, 2006 2:44 PM
  • User1533001300 posted

    Hi AaronUltrasoft

    Have a look at my reply to Caddre. Try changing the theme folder to something different.


    In the end what I did was to do a small solution with a class library in and a website in to try and replicate the error. Managed to get the control working from a class library and when I ported it over to my main solution caused an error again. My solution after trailing through the compiler generated code was to change the theme name from MyProject to MyProjectTheme.


    Hope that helps

    Saturday, November 11, 2006 2:48 PM
  • User1723362981 posted


    Yes, you are right. The problem is the same name assembly and theme.

    Best practice is set theme name different of assembly name, for example:

    Assembly: MyAssembly.UI

    Theme: MyAssembly_Theme

     Do not override Page_Load or Page_Init events in custom controls, cause it can be an error using UpdatePanel in controls inside your custom control!

    Wednesday, March 12, 2008 4:45 AM
  • User716614994 posted

    You're Right!

    Thats it! ;D 

    Thursday, April 17, 2008 4:01 PM