Web Custom Control CSS Not Displaying at Design Time

Last post 03-13-2008 2:08 PM by biznick. 3 replies.

Sort Posts:

  • Web Custom Control CSS Not Displaying at Design Time

    03-12-2008, 10:24 PM
    • Loading...
    • biznick
    • Joined on 02-15-2007, 4:19 PM
    • Posts 20

    I have been spending some time now working on my first major web custom control.  This control has images and a css file, so I decided to try and embed these into my control's assembly.

    I added my images, made then embedded resources, referenced them in my AssemblyInfo and called them properly, and they are displaying great.

    I did the same thing for my CSS file, and while it does display when I open my website with the custom control, I can get the CSS to display when in design time.  Has anyone had any experience with this who can help.

    My assembly has the following line added

     [assembly: WebResource("CustomControlStyle.css", "text/css")]

    And my custom control has the following code located in the OnInit method

    string includeTemplate = "<link rel='stylesheet' type='text/css' href='{0}' />";
    string includeLocation = Page.ClientScript.GetWebResourceUrl(typeof(MyCustomControl), "CustomControlStyle.css");
    LiteralControl include = new LiteralControl(String.Format(includeTemplate, includeLocation));
    Page.Header.Controls.Add(include);

    Again, the css and images are both displaying when I view the site in my browser.  However, when I'm in design time, the images show, but the CSS does not render.  Any assistance on this would be greatly appreciated Smile

  • Re: Web Custom Control CSS Not Displaying at Design Time

    03-13-2008, 9:46 AM
    • Loading...
    • biznick
    • Joined on 02-15-2007, 4:19 PM
    • Posts 20

    I don't normally give my post a bump, but my view total was at around 14 (and I think most of them where me!) :)..

    I guess thats what happens when I post late at night :)  Anyways, if anyone has any idea what could be causing my issue above, I'd greatly apprectiate some assistance. 

  • Re: Web Custom Control CSS Not Displaying at Design Time

    03-13-2008, 12:32 PM
    Answer
    • Loading...
    • imran.nathani
    • Joined on 04-07-2006, 9:32 AM
    • Toronto,Canada
    • Posts 836

    css is  totally at the browser...so technically it shud not load until in the browser...

    but in visual studio some simple css does load.....also if u use expression web most css wud.

    also.....diffrent domain /folder etc also affects this

  • Re: Web Custom Control CSS Not Displaying at Design Time

    03-13-2008, 2:08 PM
    • Loading...
    • biznick
    • Joined on 02-15-2007, 4:19 PM
    • Posts 20

    The CSS I'm using does load if I just place a css file in my normal webpage.  It only doesn't load as an embedded resource (in which case not in design, but then loads in the browser).

    Thanks for the information, I appreciate it.  I had a feeling the CSS just would not load if embedded.

Page 1 of 1 (4 items)
Microsoft Communities
Page view counter