Groups | Blog | Home
all groups > asp.net webcontrols > november 2003 >

asp.net webcontrols : how to persist my CustomControl's subcontrol


lao.pan
11/28/2003 11:37:50 PM
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]
12/1/2003 8:53:18 PM
Denis Bauer has a control that recreates dynamic controls on subsequent
requests.

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

[quoted text, click to view]

AddThis Social Bookmark Button