Hello Rolf,
As for the custom webcontrol, based on the code you provided, I found there
are two things we may take care here:
1) If you want to persist Control's properties inside Control's tag(inner
property), you need to set the "ParseChildrenA ttribute" as "true", this
indicate that the inner content of the control tag will be parsed as
control properties.
#ParseChildrenA ttribute Class
http://msdn2.microsoft.com/en-us/lib...ildrenattribut
e.aspx
2) The "PersistChildre nAttributeA" is used together with the
"parseChildrenA ttribute", from the MSDN document remark below:
=============== ====
The PersistChildren Attribute is used in combination with the
ParseChildrenAt tribute to determine how nested content of a control is
interpreted. If PersistChildren Attribute is true and ParseChildrenAt tribute
is false, the nested content contained within an ASP.NET server control is
persisted as controls.If PersistChildren Attribute is false and
ParseChildrenAt tribute is true, the nested content is persisted as
properties of the server control.
=============
You can find that if you want to persist property into control's inner
content, you should set "PersistChildAt tribute" to false and
"ParseChildrenA ttribute" to true. e.g.
[ParseChildren(t rue,"Descriptio n")]
[PersistChildren (false)]
Here is a complete test control for your reference:
=============== =============== ====
[DefaultProperty ("Descriptio n")]
[ToolboxData("<{ 0}:PropertyCont rol
runat=server></{0}:PropertyCon trol>")]
[ParseChildren(t rue,"Descriptio n")]
public class PropertyControl : WebControl
{
[Bindable(true)]
[Category("Appea rance")]
[DefaultValue("" )]
[Localizable(tru e)]
public string Text
{
get
{
String s = (String)ViewSta te["Text"];
return ((s == null) ? String.Empty : s);
}
set
{
ViewState["Text"] = value;
}
}
[Bindable(true)]
[Category("Appea rance")]
[DefaultValue("d efault description")]
[Localizable(tru e)]
[PersistenceMode (PersistenceMod e.InnerDefaultP roperty)]
public string Description
{
get
{
String s = (String)ViewSta te["Descriptio n"];
return ((s == null) ? String.Empty : s);
}
set
{
ViewState["Descriptio n"] = value;
}
}
protected override void RenderContents( HtmlTextWriter output)
{
output.Write("< br/><hr/>");
output.Write("< br/>Text: " + Text);
output.Write("< br/>Description: " + Description);
output.Write("< br/><hr/>");
}
}
=============== =============== ===
Hope this helps.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.