locked
Enable/Disable CSSFriendly via property RRS feed

  • Question

  • User59752322 posted

    I've got this working very nicely and customized the code to do exactly what I want (output in ' li ') so that I got down no sweat.

    what I would like to do is make "EnableAdapter" a property for treeview.  The project calls for this (admin side = "don't care" and public face = "as compliant as humanly possible") and I first tried something like this...don't laugh, I'm new at this custom control thing

    1        Public Class AdaptedTreeView
    2            Inherits TreeView
    3    
    4            Private _enableAdapter As New Boolean
    5    
    6            Public Property EnableAdapter()
    7                Get
    8                    Return _enableAdapter
    9    
    10               End Get
    11               Set(ByVal value)
    12                   _enableAdapter = value
    13               End Set
    14           End Property
    15   
    16           Private Function IsEnabledAdapter() As Boolean
    17               Return _enableAdapter
    18           End Function
    19   
    20       End Class
    
     

    Seems simple enough, and I go to sneak in a little present into the Override OnLoad in the TreeViewAdapter.cs like this (well, it didn't work, but I was hoping)

            Protected Overrides Sub OnLoad(ByVal e As EventArgs)
                MyBase.OnLoad(e)
    
                Dim treeView As AdaptedTreeView = CType(Control, AdaptedTreeView)
                If (treeView.EnableAdapter) Then

    I went into the .designer.vb trying to be sneaky and changed the type out, but no luck, comes up with

    Parser Error Message: The base class includes the field 'TreeView1', but its type (CMS.Web.UI.CSSFriendly.AdaptedTreeView) is not compatible with the type of control (System.Web.UI.WebControls.TreeView). 

    I got my property but I'm not sure how exactly ...wait, let me guess, compile a dll and add that as a control to my toolbox and drag/drop?  Or I guess I could drop a panel or placeholder on the page and do a controls.add?

    and further, anyone have a better idea/method/idea on how to do this?

    Friday, February 15, 2008 4:10 PM

All replies

  • User-1385398420 posted

    What is CMS.Web.UI.CSSFriendly.AdaptedTreeView? It appears you are using your own subclassed implementation of the TreeView control? If so, this control would already by default not use the CSS control extenders, unless you registered that class (under the App_Browsers directory). As well, you'd have to change your OnLoad method to this:

    The easiest way to have on adapted and one non-adapted version of the control is to do this:

    1. Implement the CSS adapters as normal.
    2. Use the default classes for adapted rendering.
    3. Create your own classes of controls inheriting from the default controls for each control you don't want adapted, and use those for non-adapted controls.

    Your error is probably a result of your aspx page, aspx.vb page, and aspx.designer.vb page being out of sync (i.e. one using TreeView the ohter using AdaptedTreeView).

     

    Sunday, February 17, 2008 4:29 PM