css processing in VS.NET IDE

Discussion in 'ASP .Net Web Controls' started by raffi, Jul 28, 2003.

  1. raffi

    raffi Guest

    I work on a project where a custom control exists to
    select a stylesheet at runtime based on a user's profile
    and to ouptut the relevant tag. This works
    fine.

    However, at design time it is a pain to use the VS.NET
    Designer b/c the application's default stylesheet is not
    applied. Most developers just hard-code a tag
    to the default stylesheet while laying out their pages.
    Predictably, many forget to remove the link before
    checking the page in. I figured it would be easy enough
    to write a custom control that does nothing at run-time
    but at design time uses a custom designer to spit out a
    tag to the default CSS page to make the VS.NET
    Designer usable for page layout.

    Problem is, the custom designer code executes and appears
    to be spitting out the tag just fine but the VS.NET
    Designer never respects it and updates the controls
    appearance based on the linked stylesheet. I assume the
    problem has to do with ordering of steps the VS.NET
    Designer takes when painting the design view but (1) I
    don't know what those steps are exactly, and (2) I am
    currently at a loss on how to proceed to get the Designer
    to respect the custom control's output.

    Here is a very simple test case using inline styles (they
    exhibit the exact same issues and simplify the test case):

    using System;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.Design;
    using System.ComponentModel;

    namespace NI.DelphiNET.CommonWebControls
    {
    ///
    /// Summary description for DesignTimeStyleSheet.
    ///
    [ToolboxData("<{0}:DesignTimeStyleSheet
    runat=server>")]
    [Designer(typeof(DesignTimeStyleSheetDesigner))]
    public class DesignTimeStyleSheet :
    System.Web.UI.WebControls.WebControl
    {
    protected override void Render
    (HtmlTextWriter output)
    {
    // DO NOTHING AT RUNTIME!
    }
    }

    public class DesignTimeStyleSheetDesigner :
    ControlDesigner
    {
    public override bool
    DesignTimeHtmlRequiresLoadComplete
    {
    get
    {
    return true;
    }
    }

    public override string GetDesignTimeHtml()
    {
    string style = "";
    return style;
    }

    }
    }
     
    raffi, Jul 28, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hubert Hung-Hsien Chang
    Replies:
    2
    Views:
    540
    Michael Foord
    Sep 17, 2004
  2. Replies:
    5
    Views:
    960
    Axel Straschil
    Apr 6, 2005
  3. Ilias Lazaridis
    Replies:
    6
    Views:
    495
    Ilias Lazaridis
    Jan 28, 2006
  4. Ilias Lazaridis
    Replies:
    13
    Views:
    280
    Ilias Lazaridis
    Apr 12, 2005
  5. Ilias Lazaridis
    Replies:
    0
    Views:
    134
    Ilias Lazaridis
    Jan 26, 2006
Loading...

Share This Page