Limit the scope of control adapters RRS feed

  • Question

  • User1893902719 posted


    I have a website consisting of a 3rd party CMS (lots of admin pages) and a lot of templates.

    I'd like the adapters to apply to my templates but no to the admin pages.

    Is there a way to limit the scope of the adapters?


    The only way I have thought of is to create new Types that inherit from the base asp control and then associate the adapter with those sub-types, but that seems like a big ugly hack to me.




    Wednesday, May 6, 2009 7:06 PM

All replies

  • User1755148464 posted

     Hey Murray. I've been searching for a way to do exactly the same thing. Judging from what I've found, the thought you had is exactly what you have to do. See the last post in this thread on CSS Friendly's CodePlex page: http://cssfriendly.codeplex.com/Thread/View.aspx?ThreadId=15361

     It would be nice if we could have something as simple as a property for a base class like Adapted="True" or "False." 

    Friday, June 12, 2009 2:13 PM
  • User1893902719 posted

     I would like to exclude the adapter from certain 'folder' or 'url'

    because I don't want to have to change all the attributes on half of the site. :-)

    I suppose I could update all the CSS friendly adapters to check the url, and use thier own render or the base.render depending on that.

    then write some kind of configuration into the web.config.

    Tuesday, June 16, 2009 12:33 AM
  • User1755148464 posted

    Ugh. Yeah, that could probably be done. I feel like there's an easier solution, but feelings aren't going to help. I've tried implementing the only solution I've come across--inheriting from the ASP .NET server controls and associating the adapters with the new controls. However, I must be doing something wrong, because I keep getting the error that my control "is not allowed here because it does not extend class 'System.Web.UI.UserControl'." I'm not sure what to make of that, since my new DataList inherits the DataList exactly the way the previous example's menu inherits from Menu.

    This solution isn't perfect, but it allows you distinct control over which Controls are adapted and which aren't... that is, if I could get it to work. :(

    Tuesday, June 16, 2009 9:48 AM
  • User1755148464 posted

     Okay, it finally works. The last piece of the puzzle was the @Register directive. This page helped me figure that out: http://www.vbinfozine.com/a_aspnet_derived_ctl.shtml

    Here are the steps I took:

    1. Create a new class that inherits the control you want (modeled after the menu class in the OrbitOne example posted above)

     I just included this as part of my CSSFriendly project, and within the CSSFriendly namespace.

    2. Modify the *.browser file to point to the new class (i.e., CSSFriendly.Whatever)

    3. To use the control on a page, the @Register directive looks like this:


    <%@ Register TagPrefix = "tag"
    Namespace = "CSSFriendly"
    Assembly = "CSSFriendly" %>
    Namespace is the namespace in which your new control resides. Assembly is whatever *.dll contains the code. In my case, since I made my control part of the CSSFriendly project, both of these are CSSFriendly. I'm happy to provide any assistance if you decide you want to use this solution (you probably won't have any problems with it.. I feel like the @Register problem I had was pretty amateurish, but I'm a C++ programmer by nature [:P]).
    Tuesday, June 16, 2009 10:08 AM