Why the designer doesn't persist the property of my control? (Advanced)

Discussion in 'ASP .Net' started by Umut Tezduyar, Dec 2, 2005.

  1. I have build a sample control but the designer doesn't communicate it to
    parse the childen. Please if you are an control developer, spend your 10
    minutes to solve my problem.

    The main problem is, whenever i made a change in the sub object (Tab) it
    doesn't persist the changes to the asp.net page.

    Here is the code sample:

    ---------- Asp Page ----------------

    <form id="Form1" method="post" runat="server">
    <cc1:Umut runat="server" id="umut1ew">
    <Tab name="main">
    <Tabs>
    <cc1:Tab name="sub1"/>
    <cc1:Tab name="sub2"/>
    </Tabs>
    </Tab>
    </cc1:Umut>
    </form>

    --------------------------------------




    [
    System.ComponentModel.TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter)), System.Web.UI.ControlBuilder(typeof(System.Web.UI.ControlBuilder)) ] public class Tab { private ArrayList _tabs; private string _name; public Tab() { } [ System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty) ] public ArrayList Tabs { get { if (this._tabs == null) this._tabs = new System.Collections.ArrayList(); return this._tabs; } set { this._tabs = value; } } [ System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.Attribute) ] public string Name { get { return this._name; } set { this._name = value; } } } [ System.ComponentModel.Designer(typeof(System.Web.UI.Design.ControlDesigner)), System.Web.UI.ParseChildren(true) ] public class Umut : System.Web.UI.Control { private Tab _tab; public Tab Tab { get { if (this._tab == null) { this._tab = new Tab(); this._tab.Name = "Default"; } return this._tab; } set { this._tab = value; } } protected override void Render(System.Web.UI.HtmlTextWriter writer) { this.RenderTab (writer, this.Tab); } private void RenderTab(System.Web.UI.HtmlTextWriter writer, Tab tab) { writer.Write (string.Format (">>Tab name={0}<br>", tab.Name)); foreach (Tab t in tab.Tabs) this.RenderTab (writer, t); } }
     
    Umut Tezduyar, Dec 2, 2005
    #1
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.