aaronbdavis
12-28-2006, 01:22 PM
I am developing a user control with the following structure:
<div id="divContainter" runat="server">
<!-- other controls here -->
</div>
I want all Styles changed to the control to be propagated to the divContainer. I.e, I want<foo:mycontrol runat="server" style="background-color:blue"/> to be rendered as <div id="divContainter" runat="server" style="background-color:blue">
<!-- other controls here -->
</div>
I have defined the style property in the code behind as follows:public System.Web.UI.CssStyleCollection Style
{
get { return this.divContainer.Style; }
set
{
foreach ( string key in value.Keys )
{
this.divContainer.Style[key] = value[key];
}
}
}
This works correctly when I am modifying the Style property in the code behind, but when I try to declare it in the markup, I get the following errorCannot create an object of type 'System.Web.UI.CssStyleCollection' from its string representation
I have tried inheriting from classes besides UserControl, but many of them don't have access to some properties that I need. Does anyone know how to get around this?
<div id="divContainter" runat="server">
<!-- other controls here -->
</div>
I want all Styles changed to the control to be propagated to the divContainer. I.e, I want<foo:mycontrol runat="server" style="background-color:blue"/> to be rendered as <div id="divContainter" runat="server" style="background-color:blue">
<!-- other controls here -->
</div>
I have defined the style property in the code behind as follows:public System.Web.UI.CssStyleCollection Style
{
get { return this.divContainer.Style; }
set
{
foreach ( string key in value.Keys )
{
this.divContainer.Style[key] = value[key];
}
}
}
This works correctly when I am modifying the Style property in the code behind, but when I try to declare it in the markup, I get the following errorCannot create an object of type 'System.Web.UI.CssStyleCollection' from its string representation
I have tried inheriting from classes besides UserControl, but many of them don't have access to some properties that I need. Does anyone know how to get around this?