WebControl :: inner html content of the control is being deleted

Discussion in 'ASP .Net Building Controls' started by Andrew, Sep 17, 2003.

  1. Andrew

    Andrew Guest

    Hi,

    I'm working on a control that produces Culture specific output.

    I have the runtime behavior that I want, I have a problem at design time.

    The core issue is that the inner html content of the control is being
    deleted when I change a property in the properties window


    I've include a bit of working test code to simplify seeing the issues.
    I have not included code for a designer, as I only use PreFilterProperties
    to hide the base classes props.

    To use the test control I have an aspx with this:
    <%@ Register TagPrefix="cc1" Namespace="CustomWebControls"
    Assembly="CustomWebControls" %>
    <cc1:SaveChildren id="SaveChildren1" runat="server">
    <Text CultureName=""></Text>
    </cc1:SaveChildren>

    The way I have coded it here, there is only one <Text ..> element allowed,
    but I want many.
    i.e.
    <cc1:SaveChildren id="SaveChildren1" runat="server">
    <Text CultureName="en">English</Text>
    <Text CultureName="fr">Anglais</Text>
    <Text CultureName="es">Ingles</Text>
    </cc1:SaveChildren>

    I don't want this property/collection to be visible/editable in the
    properties window,
    only in the html view, but removing it in PreFilterProperties removes it
    completely.

    I have done a lot of design-time for control,
    but I haven't seen a complete example for child control collections like
    this.

    One of the strange things in this example is that if you remove the
    cultureName
    property from theChild (and the attribute from html) the element will be
    removed when you change a prop in the properties window

    Victor (vga) : I saw a couple posts like this one
    http://groups.google.com/groups?hl=...%3Amicrosoft.public.dotnet.framework.aspnet.*
    but if I specify ParseChildren and PersistChildren it gets worse.






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

    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;
    using System.Collections;
    using System.Threading;
    using System.Globalization;

    namespace CustomWebControls
    {
    //[ParseChildren(true)]
    //[PersistChildren(true)]
    public class SaveChildren : WebControl
    {
    public SaveChildren(){}

    private theChild saveControl;

    [PersistenceModeAttribute(PersistenceMode.InnerProperty)]
    public theChild Text
    {
    get
    {
    string currentCulture =
    Thread.CurrentThread.CurrentUICulture.ToString();
    return (theChild)saveControl;
    }
    set
    {
    saveControl = value;
    this.Controls.Add(value);
    }
    }
    protected override void Render(HtmlTextWriter output)
    {
    output.Write("HERE");
    }
    }
    public class theChild :HtmlGenericControl
    {
    string cultureName="";
    public string CultureName
    {
    get{return cultureName;}
    set{cultureName = value;}
    }
    public theChild(string tagName):base(tagName){}
    protected override void Render(HtmlTextWriter output)
    {
    RenderChildren(output);
    }
    }
    }
     
    Andrew, Sep 17, 2003
    #1
    1. Advertising

  2. Andrew

    Andrew Guest

    Examples from Microsoft that have the same problem!!!

    ParseChildrenAttribute Sample
    http://msdn.microsoft.com/library/d...de/html/cpconparsechildrenattributesample.asp

    SimpleInnerContent
    http://samples.gotdotnet.com/quicks...bforms/ctrlauth/simple/SimpleInnerContent.src


    -Andrew

    "Andrew" <astevenson at versus dot com> wrote in message
    news:...
    > Hi,
    >
    > I'm working on a control that produces Culture specific output.
    >
    > I have the runtime behavior that I want, I have a problem at design time.
    >
    > The core issue is that the inner html content of the control is being
    > deleted when I change a property in the properties window
    >
    >
    > I've include a bit of working test code to simplify seeing the issues.
    > I have not included code for a designer, as I only use PreFilterProperties
    > to hide the base classes props.
    >
    > To use the test control I have an aspx with this:
    > <%@ Register TagPrefix="cc1" Namespace="CustomWebControls"
    > Assembly="CustomWebControls" %>
    > <cc1:SaveChildren id="SaveChildren1" runat="server">
    > <Text CultureName=""></Text>
    > </cc1:SaveChildren>
    >
    > The way I have coded it here, there is only one <Text ..> element allowed,
    > but I want many.
    > i.e.
    > <cc1:SaveChildren id="SaveChildren1" runat="server">
    > <Text CultureName="en">English</Text>
    > <Text CultureName="fr">Anglais</Text>
    > <Text CultureName="es">Ingles</Text>
    > </cc1:SaveChildren>
    >
    > I don't want this property/collection to be visible/editable in the
    > properties window,
    > only in the html view, but removing it in PreFilterProperties removes it
    > completely.
    >
    > I have done a lot of design-time for control,
    > but I haven't seen a complete example for child control collections like
    > this.
    >
    > One of the strange things in this example is that if you remove the
    > cultureName
    > property from theChild (and the attribute from html) the element will be
    > removed when you change a prop in the properties window
    >
    > Victor (vga) : I saw a couple posts like this one
    >

    http://groups.google.com/groups?hl=...%3Amicrosoft.public.dotnet.framework.aspnet.*
    > but if I specify ParseChildren and PersistChildren it gets worse.
    >
    >
    >
    >
    >
    >
    > using System;
    > using System.ComponentModel;
    > using System.Web;
    > using System.Web.UI;
    > using System.Web.UI.Design;
    >
    > using System.Web.UI.WebControls;
    > using System.Web.UI.HtmlControls;
    > using System.Collections;
    > using System.Threading;
    > using System.Globalization;
    >
    > namespace CustomWebControls
    > {
    > //[ParseChildren(true)]
    > //[PersistChildren(true)]
    > public class SaveChildren : WebControl
    > {
    > public SaveChildren(){}
    >
    > private theChild saveControl;
    >
    > [PersistenceModeAttribute(PersistenceMode.InnerProperty)]
    > public theChild Text
    > {
    > get
    > {
    > string currentCulture =
    > Thread.CurrentThread.CurrentUICulture.ToString();
    > return (theChild)saveControl;
    > }
    > set
    > {
    > saveControl = value;
    > this.Controls.Add(value);
    > }
    > }
    > protected override void Render(HtmlTextWriter output)
    > {
    > output.Write("HERE");
    > }
    > }
    > public class theChild :HtmlGenericControl
    > {
    > string cultureName="";
    > public string CultureName
    > {
    > get{return cultureName;}
    > set{cultureName = value;}
    > }
    > public theChild(string tagName):base(tagName){}
    > protected override void Render(HtmlTextWriter output)
    > {
    > RenderChildren(output);
    > }
    > }
    > }
    >
    >
     
    Andrew, Sep 18, 2003
    #2
    1. Advertising

  3. Andrew

    Steve Conrad Guest

    I have the same problem of inner html being deleted when a property is
    changed.
    Has an answer to this problem been posted?

    Steve


    "Andrew" <astevenson at versus dot com> wrote in message
    news:...
    > Hi,
    >
    > I'm working on a control that produces Culture specific output.
    >
    > I have the runtime behavior that I want, I have a problem at design time.
    >
    > The core issue is that the inner html content of the control is being
    > deleted when I change a property in the properties window
    >
    >
    > I've include a bit of working test code to simplify seeing the issues.
    > I have not included code for a designer, as I only use PreFilterProperties
    > to hide the base classes props.
    >
    > To use the test control I have an aspx with this:
    > <%@ Register TagPrefix="cc1" Namespace="CustomWebControls"
    > Assembly="CustomWebControls" %>
    > <cc1:SaveChildren id="SaveChildren1" runat="server">
    > <Text CultureName=""></Text>
    > </cc1:SaveChildren>
    >
    > The way I have coded it here, there is only one <Text ..> element allowed,
    > but I want many.
    > i.e.
    > <cc1:SaveChildren id="SaveChildren1" runat="server">
    > <Text CultureName="en">English</Text>
    > <Text CultureName="fr">Anglais</Text>
    > <Text CultureName="es">Ingles</Text>
    > </cc1:SaveChildren>
    >
    > I don't want this property/collection to be visible/editable in the
    > properties window,
    > only in the html view, but removing it in PreFilterProperties removes it
    > completely.
    >
    > I have done a lot of design-time for control,
    > but I haven't seen a complete example for child control collections like
    > this.
    >
    > One of the strange things in this example is that if you remove the
    > cultureName
    > property from theChild (and the attribute from html) the element will be
    > removed when you change a prop in the properties window
    >
    > Victor (vga) : I saw a couple posts like this one
    >

    http://groups.google.com/groups?hl=...sting.google.com&rnum=3&prev=/groups?hl=en&lr
    %3D%26ie%3DUTF-8%26oe%3DUTF-8%26q%3Dcontrol%2Bdesigner%2Binner%2Bproperty%2B
    group%253Amicrosoft.public.dotnet.framework.aspnet.buildingcontrols%2Bgroup%
    253Amicrosoft.public.dotnet.framework.aspnet.*
    > but if I specify ParseChildren and PersistChildren it gets worse.
    >
    >
    >
    >
    >
    >
    > using System;
    > using System.ComponentModel;
    > using System.Web;
    > using System.Web.UI;
    > using System.Web.UI.Design;
    >
    > using System.Web.UI.WebControls;
    > using System.Web.UI.HtmlControls;
    > using System.Collections;
    > using System.Threading;
    > using System.Globalization;
    >
    > namespace CustomWebControls
    > {
    > //[ParseChildren(true)]
    > //[PersistChildren(true)]
    > public class SaveChildren : WebControl
    > {
    > public SaveChildren(){}
    >
    > private theChild saveControl;
    >
    > [PersistenceModeAttribute(PersistenceMode.InnerProperty)]
    > public theChild Text
    > {
    > get
    > {
    > string currentCulture =
    > Thread.CurrentThread.CurrentUICulture.ToString();
    > return (theChild)saveControl;
    > }
    > set
    > {
    > saveControl = value;
    > this.Controls.Add(value);
    > }
    > }
    > protected override void Render(HtmlTextWriter output)
    > {
    > output.Write("HERE");
    > }
    > }
    > public class theChild :HtmlGenericControl
    > {
    > string cultureName="";
    > public string CultureName
    > {
    > get{return cultureName;}
    > set{cultureName = value;}
    > }
    > public theChild(string tagName):base(tagName){}
    > protected override void Render(HtmlTextWriter output)
    > {
    > RenderChildren(output);
    > }
    > }
    > }
    >
    >
     
    Steve Conrad, Nov 3, 2003
    #3
    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. Mike Kennedy
    Replies:
    3
    Views:
    413
    Richard Tobin
    Nov 29, 2003
  2. will551

    map elements being deleted

    will551, Dec 5, 2006, in forum: C++
    Replies:
    5
    Views:
    336
    will551
    Dec 6, 2006
  3. Chris McFarling
    Replies:
    0
    Views:
    392
    Chris McFarling
    Sep 25, 2008
  4. Replies:
    0
    Views:
    446
  5. Chumley the Walrus
    Replies:
    2
    Views:
    277
    Tom Gosselin
    Aug 10, 2004
Loading...

Share This Page