2.0 UserCtrol and Styles
-
I'm building the proverbial "Address" control for our site. I don't want to hard-code the style attributes, but instead allow the developer to control the Styles for the Address Control just like the GridViews. However, even though I have a public proeprty of say "LabelStyle" that's of type "System.Web.UI.WebControls.Style", everytime I load it in the designer the designer complains that there is no such property on "System.Web.UI.UserControl". However, I DO see the element in the markup!
<uc1:AddressControl ID="AddressControl1" runat="server">
<LabelStyle CssClass="textFontLabel" />
<EditorStyle CssClass="textFont" />
</uc1:AddressControl>How can I get this to work properly? Or can this not be done with UserControls? Do I need to use a CompositeControl?
-
I'm building the proverbial "Address" control for our site. I don't want to hard-code the style attributes, but instead allow the developer to control the Styles for the Address Control just like the GridViews. However, even though I have a public proeprty of say "LabelStyle" that's of type "System.Web.UI.WebControls.Style", everytime I load it in the designer the designer complains that there is no such property on "System.Web.UI.UserControl". However, I DO see the element in the markup!
<uc1:AddressControl ID="AddressControl1" runat="server">
<LabelStyle CssClass="textFontLabel" />
<EditorStyle CssClass="textFont" />
</uc1:AddressControl>How can I get this to work properly? Or can this not be done with UserControls? Do I need to use a CompositeControl?
If you want to make it work with the designer, you'll have to use a custom control (CompositeControl) instead as the design-time support for the usercontrol is limited in VS, it always looks at the base class
UserControl
to parse any nested elements you define in your user control.