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