Page view counter

Serving suggestion

Last post 02-26-2007 2:51 PM by bdemarzo. 11 replies.

Sort Posts:

  • Serving suggestion

    10-31-2006, 10:15 PM
    • Loading...
    • Padgett
    • Joined on 11-01-2006, 3:13 AM
    • Posts 6
    • Points 12

    I’d like to make a suggestion in regards to how this project is packaged.  This is aimed at those who want to add Css based controls to their existing project and are not concerned with how it all works.  In addition to your source and example packages, I’d love to see a ‘redistributable’ package.  This would contain just the elements needed to override the rendering of the controls.  I see this as being:

    a)       A single dll with which to reference in our existing projects.  This dll contains all the code and resources for the control adapters.

    b)       A .browser file that tells our projects to use the control adapters in the referenced assembly

     

    Is this do-able?

     

    Overall this project is excellent.  In my opinion this is how the asp.net controls should have been built in the first place.

  • Re: Serving suggestion

    11-01-2006, 11:25 AM
    • Loading...
    • Russ Helfand
    • Joined on 09-14-2005, 6:22 PM
    • Groovybits.com
    • Posts 741
    • Points 3,298

    This is a great idea. I know of a few people who have already implemented it.  I'll contact one of them, Polita Paulus, who is part of the ASP.NET team, to see if she can post some notes on how exactly to do this packaging yourself.

    I understand that you'd prefer for MS to do this DLL construction for you and merely distribute it in a future rev of the kit.  I'll keep that in mind but Polita's (or others') recipe for how to do this can help you and others right now.  So, let's try to get a detailed set of instructions posted here if we can.

    Again, thanks for the insight on how you'd prefer the kit packaged.  It's a good idea.

    Russ Helfand
    Groovybits.com
  • Re: Serving suggestion

    11-01-2006, 4:08 PM
    • Loading...
    • HardyE
    • Joined on 07-17-2002, 4:54 AM
    • Munich, Germany
    • Posts 4
    • Points 20
    • TrustedFriends-MVPs

    Hi!

    For the release of the Blinq prototype I compiled the necessary adapter resources into a dll to keep the project files clear of unrelated adapter code so developers would be able to concentrate on the core Blinq files. The CSS Adapters were in an early stage at the time but the principle can just as well be applied to the current release.

    The way to go about "pre-packaging" the adapters resources into a single dll is as follows:

    1. Create a class-library project in Visual Studio. Name it "CSSAdapters". This will hold the resources and code files which will eventually be turned into the dll.

    2. Add a "CSS Friendly ASP.NET Control Adapters" web site to the solution in Visual Studio.

    3. Reference the class library project from the Adapters project. This will ensure the output of the class library project will be copied to the Adapter project's "bin" directory.

    4. Move (don't copy) the following folders and their contents from the Adapters project to the dll project:
    - App_Code/Adapters
    - CSS
    - JavaScript
    The .cs/.vb files can be moved to the root directory of the class library project, but I recommend leaving the .css and .js files in their respective folders. The steps below assume this is the case.

    5. Open the file "AssemblyInfo.cs" of the class library project. You will need add to this file in the next step.

    6. Turn the CSS and JavaScript files residing in the "CSS" and "JavaScript" directories of the class library project into embedded resources:
    a) Select a file in Solution Explorer.
    b) In the properties window set its build action to "Embedded Resource".
    c) Add a WebRessourceAttribute decoration for the resource of step a to "AssemblyInfo.cs". For JavaScript files this must look as follows:

    [assembly: WebResource("CssAdapters.JavaScript.AdapterUtils.js", "application/x-javascript")]

    For CSS files the format would be:

    [assembly: WebResource("CssAdapters.CSS.Menu.css", "text/css")]


    The first parameter of the WebResourceAttribute expects the following syntax: ProjectNamespace.Foldername.Filename.FileExtension. Note that this is strictly case-sensitive, i.e. the casing of the resource files must match the parameter's value exactly.
    d) Repeat steps a to c for each CSS and JavaScript file.

    7. Now adjust the C#/VB code in the adapter classes to retrieve the resources from the assembly instead of the file system. The method you need here is

    ClientScriptManager.GetWebResourceUrl , which which you could use as follows:

    Page.ClientScript.GetWebResourceUrl(GetType(), "CssAdapters.CSS.Menu.css"));  

    Use this call to GetWebResourceUrl() anywhere a file system path to the respective resource is required by the adapter class.

    Following the above steps will package the CSS and JavaScript resources into a single dll along with the adapter classes. Please be aware that once the files are embedded in the dll you will have to recompile and upload the assembly to your web server each time you make a change to the CSS and JavaScript files.

    Hint: the tricky part in making embedded resources work is to figure out the exact value for the first parameter of WebResourceAttribute . If you get the casing wrong, retrieval of the resource will fail silently. No exception will be thrown, the file is simply not served. A helpful method to figure out the correct string for the resource is to set the build action for all the resources to "Embedded Resource" as in step 6b and then compile the dll. Then open the dll you just compiled in ildasm.exe and double-click on the "MANIFEST" section. Somewhere you will find entries that look similarly to this:

    .mresource public CSSAdapters.CSS.Menu.css
    {
      // Offset: 0x00000E50 Length: 0x000006F7
    }

    The value after .mresource public is the precise string you have to pass to the WebResourceAttribute in step 6c.

    Hope this helps.

    Regards,

    Hardy Erlinger

    Further reading on embedded resources in ASP.NET 2.0:

    http://www.nikhilk.net/WebResourceAttribute.aspx

    http://msdn2.microsoft.com/en-us/library/system.web.ui.webresourceattribute.aspx

  • Re: Serving suggestion

    11-01-2006, 8:12 PM
    • Loading...
    • Padgett
    • Joined on 11-01-2006, 3:13 AM
    • Posts 6
    • Points 12
    HardyE - this sounds perfect, I will give it a go.  Cheers for the detailed response.
  • Re: Serving suggestion

    11-16-2006, 10:42 AM
    • Loading...
    • bdemarzo
    • Joined on 07-02-2002, 4:05 AM
    • New York
    • Posts 168
    • Points 435
    Inspired by this topic, I wrote a compiled version of the beta 3.0 CSSAdapters. You can read about it and download it from my blog site at http://demarzo.net/archive/2006/11/16/1037.aspx.
  • Re: Serving suggestion

    11-16-2006, 7:00 PM
    • Loading...
    • Thacker
    • Joined on 09-12-2006, 4:47 AM
    • Posts 11
    • Points 50

    bdemarzo---

    Your compiled dll and supplied files within your zip are excellent.  This will greatly ease deployment.  Re-compiling the dll for adjustments and later revisions to the adapters and associated files is going to be a breeze.  It keeps things simple and stupid.  It is great.  Thanks very much, ladies and gentlemen. 

  • Re: Serving suggestion

    11-16-2006, 10:01 PM
    • Loading...
    • bdemarzo
    • Joined on 07-02-2002, 4:05 AM
    • New York
    • Posts 168
    • Points 435

    Thanks for the kind words -- I'm glad you (and hopefully many others!) find it as helpful as I do. I'll keep updating the compiled distribution to coincide with the latest changes from Microsoft until they do it for me. Wink

     

  • Re: Serving suggestion

    01-29-2007, 4:23 AM
    • Loading...
    • michiel1978
    • Joined on 07-15-2005, 8:58 AM
    • Posts 250
    • Points 1,205

    Hello bdemarzo,

    your site is currently down, is this temporary? If not, would you consider moving the project to sourceforge or codeplex so we always have access and others can help with the maintenance?

    Thanks! 

    When you ask a question, remember to click "mark as answered" when you get a reply which answers your question; this ensures the right forum member gets credit below for being helpful (and makes search more relevant too).
  • Re: Serving suggestion

    01-29-2007, 10:15 AM
    • Loading...
    • bdemarzo
    • Joined on 07-02-2002, 4:05 AM
    • New York
    • Posts 168
    • Points 435

    My server crashed and I haven't had time to repair it. Should be back in a week or so.

    I will look into adding it to CodePlex this week.


     

  • Re: Serving suggestion

    01-30-2007, 3:08 PM
    • Loading...
    • michiel1978
    • Joined on 07-15-2005, 8:58 AM
    • Posts 250
    • Points 1,205
    Just realized you might not be allowed to post the source to Codeplex because you altered it (Microsoft Permissive License)?
    When you ask a question, remember to click "mark as answered" when you get a reply which answers your question; this ensures the right forum member gets credit below for being helpful (and makes search more relevant too).
  • Re: Serving suggestion

    01-30-2007, 3:16 PM
    • Loading...
    • bdemarzo
    • Joined on 07-02-2002, 4:05 AM
    • New York
    • Posts 168
    • Points 435

    michiel1978:
    Just realized you might not be allowed to post the source to Codeplex because you altered it (Microsoft Permissive License)?

    Good point. ScottGu commented on my posting of the compiled adapters, which means he's familiar with what I did (and supportive of it). I'll ask him if he has suggestions.

     

  • Re: Serving suggestion

    02-26-2007, 2:51 PM
    • Loading...
    • bdemarzo
    • Joined on 07-02-2002, 4:05 AM
    • New York
    • Posts 168
    • Points 435

    For those still interested in this, there's a few developments...


Page 1 of 1 (12 items)