Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Complex properties (Button) not persisting in webcontrol

Thread Tools

Complex properties (Button) not persisting in webcontrol

Posts: n/a
This seems to be a common issue and one that I have not found a
solution to. What I want to do is theoreticly simple. I have tried
creating webcontrols with simple properties string e.t.c and all work
fine. I am now in the process if trying to create a webcontrol that
contains more complex properties. In this case a Property of type
Button. I've played around with all of the recomended metadata
ParseChildren(true/false), PersistChildren(true/false),
PersistanceMode e.t.c. I've also been using "Developing Microsoft
ASP.NET server controls and components" by Nikhil Kothari and Vandana
Datye" but with no success in this area.

At designtime the control is rendered on the page correctly and the
Properties of the Button within the custom control appear in the
properties toolbar/palette. Changes to the Buttons properties ie. Text
or BackColor seem to take effect when the page is redrawn however
these properties do not persist.

1. There values are lost when the project is rebuilt or ran.
2. The HTML for the aspx page has not changed to reflect the new
property values.

Below is the code for the class.

using System;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Web.UI.Design;

namespace DynamicWebControls.Controls
public class TestControl:
System.Web.UI.WebControls.WebControl,INamingContai ner
Button _myButton;

protected override void CreateChildControls()

DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content),
public Button MyButton
if(_myButton==null)_myButton=new Button();

return _myButton;
_myButton = value;

protected override void Render(HtmlTextWriter writer)

Thanks in advance for your help.

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Persisting collection data of a webcontrol when leaving the collection editor in VS2005 ASP .Net Building Controls 1 05-19-2006 03:49 PM
extender provider properties not persisting ! JezB ASP .Net 1 06-22-2004 10:04 AM
Properties not persisting at design time. Steve Barker ASP .Net Building Controls 0 01-22-2004 04:56 PM
Complex properties (Button) not persisting in webcontrol Phillyboy123 ASP .Net Building Controls 1 01-15-2004 07:55 PM
Persisting properties in templates and not the control itself Alessandro Zifiglio ASP .Net Building Controls 0 11-09-2003 11:31 AM