Inheriting from System.Web.UI.WebControls.Table

J

Jimmy [Used-Disks]

I am trying to create an ASP.NET control by inheriting from Table. I would
like to stop the Rows property from being displayed/persisted at
design-time, plus I would like to have new properties I have introduced be
persisted as nested tags within my controls tag in the ASP.NET page. To do
this I have overridden the Rows property as follows:

[Browsable(false),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
PersistenceMode(PersistenceMode.InnerProperty)]
public override TableRowCollection Rows{
get{
return base.Rows;
}
}

This succesfully hides the Rows property from the properties window in the
IDE, however when other properties are persisted within the tags, it throws
an exception (at both design and run time):
"System.Web.UI.WebControls.TableRowCollection must have items of type
'System.Web.UI.WebControls.TableRow'. 'MyCustomProperty' is of type
'System.Web.UI.HtmlControls.HtmlGenericControl'."

I have also tried using "new" instead of "override" to re-declare the Rows
property and have gotten the same results.

My question is, how do I get around this? I do *not* want a
DefaultInnerProperty for my control because I am trying to generate all the
TableRows programatically and need to persist other properties as Inner
Properties. Is there any way around this, such as an attribute I can apply
to the Rows property or to my control?

Thanks -
 
J

Jimmy [Used-Disks]

My question is, how do I get around this? I do *not* want a
DefaultInnerProperty for my control because I am trying to generate all the
TableRows programatically and need to persist other properties as Inner
Properties. Is there any way around this, such as an attribute I can apply
to the Rows property or to my control?

Found it! The answer is to apply the ParseChildren(true) and
PersistChildren(false) attributes to the control class because the Table
class had overridden the WebControls default implementation which is the
behavior we desired.

Thanks for reading :).
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top