Inheriting from System.Web.UI.WebControls.Table

Discussion in 'ASP .Net Building Controls' started by Jimmy [Used-Disks], Aug 14, 2003.

  1. 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 -

    --
    -Jimmy
    Used-Disks:
    http://www.used-disks.com/
     
    Jimmy [Used-Disks], Aug 14, 2003
    #1
    1. Advertising

  2. > 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 :).

    --
    -Jimmy
    Used-Disks:
    http://www.used-disks.com/
     
    Jimmy [Used-Disks], Aug 14, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    2
    Views:
    854
    Matt Getting
    Jul 24, 2003
  2. DanG
    Replies:
    4
    Views:
    9,654
  3. Andy B
    Replies:
    2
    Views:
    3,207
    Andy B
    Apr 23, 2008
  4. Nathan Sokalski
    Replies:
    1
    Views:
    543
    Nathan Sokalski
    Jul 31, 2009
  5. Nathan Sokalski

    Inheriting System.Web.UI.WebControls.Image and RenderContents

    Nathan Sokalski, Jul 29, 2009, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    795
    Nathan Sokalski
    Jul 31, 2009
Loading...

Share This Page