css processing in VS.NET IDE

R

raffi

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;
}

}
}
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,900
Latest member
Nell636132

Latest Threads

Top