K
Karen in England
Hello,
Using ASP.NET 2.0/Visual Studio 2005 Beta 2 and programming in C#, I'm
trying to create a user control that allows nested content between its start
and end tags. From googling around I got the impression that the
ParseChildren(false) attribute was what I needed, so my code looks like this:
[ParseChildren(false)]
public partial class Box : System.Web.UI.UserControl, INamingContainer {
protected override void Render(HtmlTextWriter output) {
// irrelevant code deleted
RenderChildren(output);
// irrelevant code deleted
}
}
I can add this control to a page, and it even does what I want when I test
the page in a browser. The only trouble is, in the Visual Studio designer I
get the error message "Type 'System.Web.UI.UserControl' does not have a
public property named '<name of whatever control I try to use>'". I also
experimented with the PersistChildren attribute to no avail. Am I doing
something wrong, or is this just not supposed to work with user controls?
I tried the same thing with a web control, and it worked just fine in the
designer:
[ToolboxData("<{0}:Box runat=server></{0}:Box>")]
[ParseChildren(false)]
public class Box : WebControl, INamingContainer {
protected override void Render(HtmlTextWriter output) {
// irrelevant code deleted
RenderChildren(output);
// irrelevant code deleted
}
}
Thanks in advance for any responses,
Karen
Using ASP.NET 2.0/Visual Studio 2005 Beta 2 and programming in C#, I'm
trying to create a user control that allows nested content between its start
and end tags. From googling around I got the impression that the
ParseChildren(false) attribute was what I needed, so my code looks like this:
[ParseChildren(false)]
public partial class Box : System.Web.UI.UserControl, INamingContainer {
protected override void Render(HtmlTextWriter output) {
// irrelevant code deleted
RenderChildren(output);
// irrelevant code deleted
}
}
I can add this control to a page, and it even does what I want when I test
the page in a browser. The only trouble is, in the Visual Studio designer I
get the error message "Type 'System.Web.UI.UserControl' does not have a
public property named '<name of whatever control I try to use>'". I also
experimented with the PersistChildren attribute to no avail. Am I doing
something wrong, or is this just not supposed to work with user controls?
I tried the same thing with a web control, and it worked just fine in the
designer:
[ToolboxData("<{0}:Box runat=server></{0}:Box>")]
[ParseChildren(false)]
public class Box : WebControl, INamingContainer {
protected override void Render(HtmlTextWriter output) {
// irrelevant code deleted
RenderChildren(output);
// irrelevant code deleted
}
}
Thanks in advance for any responses,
Karen