how to persist my CustomControl's subcontrol

Discussion in 'ASP .Net Web Controls' started by lao.pan, Nov 29, 2003.

  1. lao.pan

    lao.pan Guest

    I create a custom control with subcontrol.but in design-
    time, subcontrol contents are clear by VS when I change
    any attribute of the control.
    why?
    thank!

    the main code is:
    [
    ParseChildren(false),
    ControlBuilderAttribute(typeof(MyControlBuilder)),
    ]
    public class MyCS_CustomControl: System.Web.UI.Control,
    INamingContainer
    {
    private CellCollection _Items=new
    CellCollection();

    [
    Category("Data"),
    DefaultValue(null),
    MergableProperty(false),
    PersistenceMode
    (PersistenceMode.InnerDefaultProperty),
    ]
    public virtual CellCollection Items
    {
    get { return _Items; }
    }
    }

    CellCollection is inherit from CollectionBase,Item is a
    sample class

    the html tag is:
    <custom:mycs_customcontrol id="csTableId" title="C#
    Custom1 Control Table" runat="server" columns="2"
    rows="2">
    <CUSTEM:MYCELL Text="RED"
    BackColor="red" CellID="r1c1"></CUSTEM:MYCELL>

    </custom:mycs_customcontrol></form>

    at run-time all ok, but mycell clear in designtime when
    control-attr changed.
     
    lao.pan, Nov 29, 2003
    #1
    1. Advertising

  2. Denis Bauer has a control that recreates dynamic controls on subsequent
    requests.

    http://www.denisbauer.com/ASPNETControls/DynamicControlsPlaceholder.aspx

    "lao.pan" <> wrote in message
    news:064801c3b64b$b0bf8610$...
    > I create a custom control with subcontrol.but in design-
    > time, subcontrol contents are clear by VS when I change
    > any attribute of the control.
    > why?
    > thank!
    >
    > the main code is:
    > [
    > ParseChildren(false),
    > ControlBuilderAttribute(typeof(MyControlBuilder)),
    > ]
    > public class MyCS_CustomControl: System.Web.UI.Control,
    > INamingContainer
    > {
    > private CellCollection _Items=new
    > CellCollection();
    >
    > [
    > Category("Data"),
    > DefaultValue(null),
    > MergableProperty(false),
    > PersistenceMode
    > (PersistenceMode.InnerDefaultProperty),
    > ]
    > public virtual CellCollection Items
    > {
    > get { return _Items; }
    > }
    > }
    >
    > CellCollection is inherit from CollectionBase,Item is a
    > sample class
    >
    > the html tag is:
    > <custom:mycs_customcontrol id="csTableId" title="C#
    > Custom1 Control Table" runat="server" columns="2"
    > rows="2">
    > <CUSTEM:MYCELL Text="RED"
    > BackColor="red" CellID="r1c1"></CUSTEM:MYCELL>
    >
    > </custom:mycs_customcontrol></form>
    >
    > at run-time all ok, but mycell clear in designtime when
    > control-attr changed.
    >
    >
     
    Ken Cox [Microsoft MVP], Dec 2, 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. Bonj
    Replies:
    1
    Views:
    2,075
    John M Deal
    Nov 13, 2004
  2. Ben Dewey
    Replies:
    3
    Views:
    4,925
    Ben Dewey
    Nov 1, 2005
  3. James Geurts

    Getting a subcontrol to work in a repeater

    James Geurts, Feb 17, 2004, in forum: ASP .Net Building Controls
    Replies:
    3
    Views:
    124
    Jeffrey Tan[MSFT]
    Feb 18, 2004
  4. Fred Hirschfeld

    DataBinding to a subcontrol...

    Fred Hirschfeld, Sep 18, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    146
    Fred Hirschfeld
    Sep 18, 2004
  5. Bonj

    setting focus to datagrid subcontrol

    Bonj, Nov 13, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    117
    Michelle Hlaing
    Nov 17, 2004
Loading...

Share This Page