SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Pointiest Petitions carrotflowers's Avatar
    Join Date
    Jul 2003
    Location
    Suburbs of DC (MD)
    Posts
    595
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    user control library

    Hi guys,

    I used this tute to place my user control in one library project, and access/use it in other projects within my solution: Creating and Using User Control Libraries.

    The way it works is that you add a pre-build event to your project that needs the control, which copies the control from the library project into the project that needs to use it. Thus the original remains and is maintained in the library but can be used in other projects in the solution. However upon copy it is not 'included' in the project it is copied to, it's ghosted out if you see all files/folders in your solution view.

    This worked fine locally, but once I published my project that was using the control, I'm getting the error "Parser Error Message: The file '/blah/project/dir/usercontrol.ascx' does not exist.'

    I could just include it but I'm puzzled why the tutorial never mentions this detail, yet points out how it is excluded upon the pre-build event.

    Has anyone worked on this scenario? Any thoughts?

    Thanks-
    The guy is so tough I think his beard could beat up
    Nowitzki. -Gene Wojciechowski on Baron Davis |
    last.fm: lssian

  2. #2
    SitePoint Guru Chroniclemaster1's Avatar
    Join Date
    Jun 2007
    Location
    San Diego, CA
    Posts
    784
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've been annoyed with failed solutions to the same problem. In Flash, one of the first things they teach you is to build a library .fla files which any other project can draw from and incorporate into a published flash movie. Out of the box functionality.

    What's the best practices method for creating say generic contact form code and using it across multiple websites. That's a pretty basic object oriented need to be able to update code as you develop more and more sophisticated versions of the code and have them automatically update across your websites.
    Whatever you can do or dream you can, begin it.
    Boldness has genius, power and magic in it. Begin it now.

    Chroniclemaster1, Founder of Earth Chronicle
    A Growing History of our Planet, by our Planet, for our Planet.

  3. #3
    SitePoint Wizard
    Join Date
    Feb 2007
    Posts
    1,274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What you need are custom controls as opposed to user controls. User controls are wedded to their markup which tends to be pretty coupled to the site in general (using css classes, markup style, conventions for heading levels etc). Thus, user controls were never designe to be used for multiple sites by reference. Use custom controls for that.

    Now, some find it annoying that custom contols do not have the markup part - they are all code. If you have that requirement then make sure that your problem is not something else. Reusable controls should be rich on functionality - not on markup.

    The default model for creating structure in custom controls is to manipulate the control tree by code - typically inserting child controls.

    Some controls fall in a gray area. Think the"login" control of ASP.NET. It actually needs a default layout although developers will often choose to override it. You can do something similar if you develop a control with a complex and mostly static structure: Use the ParseControl (or LoadTemplate) method to create a control from a markup string. You can package the markup string with the control as a resource, inject it or simply retrieve it from a local file.

  4. #4
    Pointiest Petitions carrotflowers's Avatar
    Join Date
    Jul 2003
    Location
    Suburbs of DC (MD)
    Posts
    595
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks honey. I will try to learn more about custom controls for sure.

    I did fix my problem. Once it was pointed out to me that the author kept it excluded so as to not have to check it into his source control, I concluded that I had no qualms in my situation. So I just included it in the project and let it go into my svn.
    The guy is so tough I think his beard could beat up
    Nowitzki. -Gene Wojciechowski on Baron Davis |
    last.fm: lssian


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •