Groups | Blog | Home
all groups > asp.net building controls > may 2004 >

asp.net building controls : Top-Level Styles: Parser complains about inner text


Ed Swartz
5/13/2004 5:24:29 PM
I'd like to support top-level styles in my control. I
created a property (per Developing Microsoft ASP.NET Server
Controls and Components). And added ViewState Load, Save,
Track, etc per the book.

When I run my app the parser complains about the BackColor="Red"
inner text. I don't see why I'm getting this error.

Ed

-- Error message

Parser Error Message: Literal content ('BackColor="Red"') is not allowed
within a 'System.Web.UI.WebControls.Style'.


-- Application .aspx fragment:

<NodeStyle>
BackColor="Red"
</NodeStyle>


-- Style Property in control:


[
Category("Style"),
Description( "The style applied to intermediate nodes." ),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerProperty)
]
public virtual Style NodeStyle
{
get
{
if( m_NodeStyle == null )
{
m_NodeStyle = new Style();

if( IsTrackingViewState )
((IStateManager)m_NodeStyle).TrackViewState();
}

return m_NodeStyle;
}
}
Scott Mitchell [MVP]
5/13/2004 8:41:13 PM
Ed, the declarative syntax would be:

<NodeStyle BackColor="Red"></NodeStyle>

hth

--

Scott Mitchell
mitchell@4guysfromrolla.com
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

AddThis Social Bookmark Button