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

A

Andrew

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);
}
}
}
 
A

Andrew

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 said:
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);
}
}
}
 
S

Steve Conrad

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 said:
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);
}
}
}
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top