Professional Web Applications Themes

Inheriting from System.Web.UI.WebControls.Table - ASP.NET Building Controls

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(DesignerSerializat ionVisibility.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 ...

  1. #1

    Default Inheriting from System.Web.UI.WebControls.Table

    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(DesignerSerializat ionVisibility.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:
    [url]http://www.used-disks.com/[/url]


    Jimmy [Used-Disks] Guest

  2. #2

    Default Re: Inheriting from System.Web.UI.WebControls.Table

    > 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 PChildren(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:
    [url]http://www.used-disks.com/[/url]


    Jimmy [Used-Disks] Guest

Similar Threads

  1. Extending System.Web.UI.WebControls.Calendar
    By John Saunders in forum ASP.NET Building Controls
    Replies: 1
    Last Post: August 1st, 10:21 PM
  2. Replies: 0
    Last Post: December 29th, 08:23 PM
  3. installing system.web.ui.webcontrols
    By Eti in forum ASP.NET Data Grid Control
    Replies: 0
    Last Post: September 23rd, 10:29 AM
  4. System.Web.UI.WebControls Namespace
    By CG in forum ASP.NET General
    Replies: 1
    Last Post: August 8th, 11:29 PM
  5. Replies: 2
    Last Post: July 24th, 06:17 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139