PLEASE HELP - Custom Control adding a skin file cause error - BC30002: Type 'WEM.Portal.TestThemeClass' is not defined.

Last post 06-18-2008 6:47 AM by Callam.Fletcher. 1 replies.

Sort Posts:

  • PLEASE HELP - Custom Control adding a skin file cause error - BC30002: Type 'WEM.Portal.TestThemeClass' is not defined.

    10-21-2006, 10:56 AM
    • Member
      332 point Member
    • Bow99
    • Member since 05-19-2004, 10:56 AM
    • Posts 79

    Hi there

     Sorry for the shout in the subject but I have been trying to skin a custom class from a class libarary I feel im just missing a little something.

     

    I have a Solution with a website and a class library (called wem.portal)

    In the class library I have a simple custom control with just a label. See bottom of this post for the full code

    In the website I call my custom control using the following register and custom tag

    <%@ Register Assembly="WEM.Portal" Namespace="WEM.Portal.UI" TagPrefix="WEMui" %>
    <WEMui:TestThemeClass runat="server" ID="someid" />

    At this point all works well (I have not yet created a skin)

     

    The problem is that when I create a skin file using the same register line of code

    <%@ Register Assembly="WEM.Portal" Namespace="WEM.Portal.UI" TagPrefix="WEMui" %>
    <WEMui:TestThemeClass runat="server" skinID="blue" />

     and run the code the compiler has trouble creating the skin theme blue because it can not define the type WEM.Portal.UI.TestThemeClass see message below

    Compilation Error

    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

    Compiler Error Message: BC30002: Type 'WEM.Portal.UI.TestThemeClass' is not defined.

     Line 129:        Private Shared __BuildControl__control64_skinKey As Object = System.Web.UI.PageTheme.CreateSkinKey(GetType(WEM.Portal.UI.TestThemeClass), "blue")

     

     

    I have managed to get the code working when the code is stored in the App_Code but when I move it to the class library it has this namespace problem

     

     

     

    My custom Class:

    Option Strict On
    Imports System
    Imports System.ComponentModel
    Imports System.Security.Permissions
    Imports System.Web
    Imports System.Web.UI
    Imports System.Web.UI.WebControls
    
    
    Namespace UI
    
    < _
                AspNetHostingPermission(SecurityAction.Demand, _
                Level:=AspNetHostingPermissionLevel.Minimal), _
                AspNetHostingPermission(SecurityAction.InheritanceDemand, _
                Level:=AspNetHostingPermissionLevel.Minimal), _
                ToolboxData("<{0}:TestThemeClass> </{0}:TestThemeClass>") _
                > _
    Public Class TestThemeClass
        Inherits CompositeControl
    
        Private LeftLabel As Label
    
    
    
        Protected Overrides Sub CreateChildControls()
            LeftLabel = New Label
            LeftLabel.ID = "lblLeftLabel"
            LeftLabel.Text = "Left List"
            LeftLabel.CssClass = "ijb"
    
            Me.Controls.Add(LeftLabel)
    
        End Sub
    
    
        Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)
    
            LeftLabel.RenderControl(writer)
        End Sub
    
    
    
        Protected Overrides Sub RecreateChildControls()
            EnsureChildControls()
        End Sub
    
    
    End Class
    
    End Namespace
     
  • Re: PLEASE HELP - Custom Control adding a skin file cause error - BC30002: Type 'WEM.Portal.TestThemeClass' is not defined.

    06-18-2008, 6:47 AM

    Hey!

     Remove the @Register bit from the top of your page and put this in web.config under system.web / pages / controls:

    <pages>

    <controls>

    <add namespace="WEM.Portal.UI" tagPrefix="WEMui" assembly="WEM.Portal"/>

    </controls>

    </pages>

    Basically when you register the control in the page it is only available to that page - doing this makes a global registration which should be recognised by the skin file.

    I think i'm posting this 2 years to late for you but it may help someone else ;)

    Cal

    SlickTouch Web Design Prague
    www.slicktouch.com
Page 1 of 1 (2 items)