Using ParseChildren attribute to load child tags - VS removes tags

Ask a Question related to ASP.NET, Design and Development.

  1. #1

    Default Using ParseChildren attribute to load child tags - VS removes tags

    I am building a poll control, nested in the tag I have child tags to setup
    the poll options.

    Everything works fine, but when I edit a property in VS design mode, VS
    removes the child tags.



    C# Code:

    [ParseChildren(true, "Options")]
    public class PollForm : Control, INamingContainer
    {
    private ArrayList options = new ArrayList();

    public ArrayList Options
    {
    get { return options; }
    }
    }


    public class Option
    {
    private string text;

    public string Text
    {
    get { return text; }
    set { text = value; }
    }
    }

    Tags:

    <MyTag:PollForm id=”poll1” runat="server">
    <MyTag:Option Text=”Option 1” />
    <MyTag:Option Text=”Option 2” />
    </MyTag:PollForm>


    How do I stop VS removing the child tags?
    Steve Guest

  2. Similar Questions and Discussions

    1. unlock head tags on child page based on template
      Is there a way to unlock the head tags and body tag of a child page that is based on a template? I can insert Flash Video on the template page, I...
    2. How to treat template tags as comment tags?
      Hi all, I am using DW MX to edit templates for a FreeMarker application. The template tag fromat is like so: <ul> <#list birds as bird>...
    3. Help needed. I Cannot find TITLE attribute for A tags
      Can anybody tell me how I can edit/add TITLE attributes in A tags? I cannot find this anywhere. Thanks Rob
    4. My Own Tags
      I am currently working on a modular system where I need to implement SNIPPETS. I need to be able to write on my php pages something like ], so that...
    5. Alt tags
      You want the alt attribute to be the same color as the background color of the cell? I'm not sure what you are asking for. The alt attribute is...
  3. #2

    Default Re: Using ParseChildren attribute to load child tags - VS removes tags

    Hi Steve,

    Take a look at the PersistChildren attribute.

    --
    Victor Garcia Aprea
    Microsoft MVP | ASP.NET
    Looking for insights on ASP.NET? Read my blog:
    [url]http://obies.com/vga/blog.aspx[/url]
    To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
    and not by private mail.

    "Steve" <Steve@Dot.Net> wrote in message
    news:ubFs26oSDHA.3768@tk2msftngp13.phx.gbl...
    > I am building a poll control, nested in the tag I have child tags to setup
    > the poll options.
    >
    > Everything works fine, but when I edit a property in VS design mode, VS
    > removes the child tags.
    >
    >
    >
    > C# Code:
    >
    > [ParseChildren(true, "Options")]
    > public class PollForm : Control, INamingContainer
    > {
    > private ArrayList options = new ArrayList();
    >
    > public ArrayList Options
    > {
    > get { return options; }
    > }
    > }
    >
    >
    > public class Option
    > {
    > private string text;
    >
    > public string Text
    > {
    > get { return text; }
    > set { text = value; }
    > }
    > }
    >
    > Tags:
    >
    > <MyTag:PollForm id="poll1" runat="server">
    > <MyTag:Option Text="Option 1" />
    > <MyTag:Option Text="Option 2" />
    > </MyTag:PollForm>
    >
    >
    > How do I stop VS removing the child tags?

    Victor Garcia Aprea [MVP] Guest

  4. #3

    Default Re: Using ParseChildren attribute to load child tags - VS removes tags

    Thanks

    this is what i finely got to work

    adding [PersistenceMode(PersistenceMode.InnerProperty)] to the public
    property


    C# Code:

    [ParseChildren(true, "Options")]
    public class PollForm : Control, INamingContainer
    {
    private ArrayList options = new ArrayList();

    [PersistenceMode(PersistenceMode.InnerProperty)]
    public ArrayList Options
    {
    get { return options; }
    }
    }


    public class Option
    {
    private string text;

    public string Text
    {
    get { return text; }
    set { text = value; }
    }
    }

    Tags:

    <MyTag:PollForm id=”poll1” runat="server">
    <MyTag:Option Text=”Option 1” />
    <MyTag:Option Text=”Option 2” />
    </MyTag:PollForm>
    Steve Guest

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