Currently I am marking this thread as “Answered”, if my reply does not help you resolve the problem, please feel free to unmark it. Please also provide the following information and we will be glad to follow up.
The error message after you tried the solution above.
Just to elarge the frustrated list, here are my thoughts...
I'm passing through this problem too.. And now it would be thankfull to receive an answer from
Microsoft Allmighty ASP.NET Developers, so my question is:
You guys sat someday talking about ASP.NET and how to develop a solid control encapsulated with
design time support (because people were no really used to write HTML that new thing that makes the
web look nice) and so you decided to wrote a WebControl deriving the Control class... so far so good,
but because some reason nobody thought or i think that nobody thought, shouldn't we develop a designer
for it ?! i bet some nerd must have said for what? you can do everything through code... but then after that
you looked and thought, oh we need a designer to drag this we developed into... so you developed a designer
were we can write HTML and drag&drop WebControls. With age we gained some maturity and we start combining
and templating and composing, and thats when you guys once again released new concepts like, templates throught
grid and details views and list views etc... and Composite Web Control etc etc.. and USER CONTROLS.. now reading
from the beginning again it pops the question, why didn't you guys developed UserControl right from the start insted
of a blind Server Control??!
I'm an Arquitect i understand, we have timmings and we lack a crystal ball ok accepted! but now that you, your clients and
the frustated social groups that talk about it, know that user controls seems to be the way, and just because it is so close to
being there why doesn't some body tells us how can we correct this unexpected behaviour??
Can Microsoft develop an hotfix and update??!!?! something
..... need help... no time... ask participation i'm sure every body in this forum agree to write a piece of code if that is what is
required to use usercontrols and gain much more in productivity...
but the final question is: How can we correct the Designer error when using ITemplates inside UserControls on the Designer,
eg:
<PhenomenalUC runat="server">
<MegaTemplate>
some text.... some binding etc
</MegaTemplate>
</PhenomenalUC>
gangelo
Member
596 Points
272 Posts
UserControl ITemplate Property Design Time Error - Easy for a Guru...
Jul 17, 2008 04:51 PM|LINK
This is driving me crazy...PLEASE HELP...Everything works fine when I run my web site - my control works/displays fine...
When in Design Time, however, I get the following error:
Error Rending Control - Control Name
An unhandled exception has occurred.
Type 'System.Web.UI.UserControl' does not have a public property named 'Header'.
HERE IS MY CODE-BEHIND:
using System; using System.Data; using System.Configuration; using System.Collections; using System.Collections.ObjectModel; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.ComponentModel; using System.IO; public class HeaderTemplate : ITemplate, INamingContainer { public HeaderTemplate() { } #region ITemplate Members public void InstantiateIn(Control container) { Literal literal = new Literal(); literal.DataBinding += new EventHandler(OnHeaderDataBinding); container.Controls.Add(literal); } public void OnHeaderDataBinding(object sender, EventArgs e) { Literal literal = (Literal)sender; RepeaterItem container = (RepeaterItem)literal.NamingContainer; object data = DataBinder.GetPropertyValue(container.DataItem, "Header"); literal.Text = data.ToString(); } #endregion }; public partial class WucCollapsibleSectionBox : System.Web.UI.UserControl, INamingContainer { private ITemplate m_headerTemplate; private ITemplate m_contentTemplate; private System.Drawing.Color m_backColor; private bool m_isCollapsed = false; /// <summary> /// Initialize the templated content /// </summary> /// <param name="e">Event arguments</param> protected override void OnInit(EventArgs e) { base.OnInit(e); //HeaderContainer.Controls.Clear(); //BodyContent.Controls.Clear(); if (m_headerTemplate == null) { HeaderContainer.Controls.Add(new LiteralControl("[No Header Defined]")); } else { m_headerTemplate.InstantiateIn(HeaderContainer); } if (m_contentTemplate == null) { BodyContent.Controls.Add(new LiteralControl("[No Content Defined]")); } else { m_contentTemplate.InstantiateIn(BodyContent); } // Initialize the BodyContent to be either expanded or collapsed depending on the flag... if (!Page.IsPostBack) { if (!Convert.ToBoolean(Session["TEXT_ONLY"])) { AjaxControlToolkit.CollapsiblePanelExtender control = FindControl("CollapsiblePanelExt") as AjaxControlToolkit.CollapsiblePanelExtender; if (control != null) { control.Collapsed = m_isCollapsed; } } } } /// <summary> /// Template for the title of the section /// </summary> [ PersistenceMode(PersistenceMode.InnerProperty), TemplateContainer(typeof(HeaderTemplate)) ] public ITemplate Header { get { return m_headerTemplate; } set { m_headerTemplate = value; } } /// <summary> /// Template for the content of the section /// </summary> [ PersistenceMode(PersistenceMode.InnerProperty), TemplateContainer(typeof(TemplateControl)) ] public ITemplate Content { get { return m_contentTemplate; } set { m_contentTemplate = value; } } /// <summary> /// Determine if the collapsible section should be initially collapsed /// </summary> [ PersistenceMode(PersistenceMode.Attribute) ] public bool IsCollapsed { get { return m_isCollapsed; } set { m_isCollapsed = value; } } /// <summary> /// Sets the background color of the body content. /// </summary> [ PersistenceMode(PersistenceMode.Attribute) ] public System.Drawing.Color BackColor { get { if (m_backColor == System.Drawing.Color.Empty) { return System.Drawing.Color.White; } else { return m_backColor; } } set { m_backColor = value; } } protected override void Render(HtmlTextWriter writer) { EnsureChildControls(); PrepareControlForRendering(); // style controls before rendering... base.Render(writer); } protected override void CreateChildControls() { //Controls.Clear(); // clear the child controls... CreateControlHierarchy(); // create the control tree... ClearChildViewState(); // clear the child view state... ChildControlsCreated = true; } protected virtual void CreateControlHierarchy() { CreateCollapsiblePanelExtender(this); ChildControlsCreated = true; } protected void CreateCollapsiblePanelExtender(Control container) { if (!Convert.ToBoolean(Session["TEXT_ONLY"])) { AjaxControlToolkit.CollapsiblePanelExtender collapsiblePanelExtender = new AjaxControlToolkit.CollapsiblePanelExtender(); collapsiblePanelExtender.ID = "CollapsiblePanelExt"; collapsiblePanelExtender.CollapseControlID = "PanelHandle"; collapsiblePanelExtender.Collapsed = false; collapsiblePanelExtender.CollapsedImage = "~/Images/expand.gif"; collapsiblePanelExtender.CollapsedSize = 0; collapsiblePanelExtender.ExpandControlID = "PanelHandle"; collapsiblePanelExtender.ExpandDirection = AjaxControlToolkit.CollapsiblePanelExpandDirection.Vertical; collapsiblePanelExtender.ExpandedImage = "~/Images/collapse.gif"; collapsiblePanelExtender.ExpandedSize = 0; collapsiblePanelExtender.ImageControlID = "HeaderImage"; collapsiblePanelExtender.ScrollContents = false; collapsiblePanelExtender.SuppressPostBack = true; collapsiblePanelExtender.TargetControlID = "BodyPanel"; container.Controls.Add(collapsiblePanelExtender); } } protected virtual void PrepareControlForRendering() { if (Controls.Count < 1) { return; } BodyTable.Style.Add("border-left", "solid 1px Gainsboro"); BodyTable.Style.Add("border-right", "solid 1px Gainsboro"); BodyTable.Style.Add("border-bottom", "solid 1px Gainsboro"); //BodyTable.Style.Add(HtmlTextWriterStyle.BackgroundColor, m_backColor.ToKnownColor().ToString()); string backColor = System.Drawing.ColorTranslator.ToHtml(this.BackColor); BodyContent.Style["filter:progid"] = string.Format( "DXImageTransform.Microsoft.Gradient(EndColorStr='{0}', StartColorStr='#ffffff', GradientType='0')", backColor); BodyContent.Style.Add(HtmlTextWriterStyle.PaddingLeft, "5px"); BodyContent.Style.Add(HtmlTextWriterStyle.PaddingTop, "0"); BodyContent.Style.Add(HtmlTextWriterStyle.PaddingRight, "5px"); BodyContent.Style.Add(HtmlTextWriterStyle.PaddingBottom, "8px"); // Body footer... BodyFooter.Style["filter:progid"] = string.Format( "DXImageTransform.Microsoft.Gradient(EndColorStr='#ffffff', StartColorStr='{0}', GradientType='0')", backColor); if (!Convert.ToBoolean(Session["TEXT_ONLY"])) { ToolbarMiddle.Style[HtmlTextWriterStyle.BackgroundImage] = ResolveClientUrl("~/Images/Misc/ToolBar_Middle.gif"); ToolbarMiddle.Style["background-repeat"] = "repeat-x"; ToolbarBottomCell.Style[HtmlTextWriterStyle.BackgroundImage] = ResolveClientUrl("~/Images/Misc/ToolBar_Bottom.gif"); ToolbarBottomCell.Style["background-repeat"] = "repeat-x"; PanelHandle.Style[HtmlTextWriterStyle.Cursor] = "pointer"; } else { PanelHandle.Style["border"] = "solid 1px gainsboro"; PanelHandle.Style[HtmlTextWriterStyle.BackgroundColor] = "WhiteSmoke"; PanelHandle.Style[HtmlTextWriterStyle.BackgroundImage] = string.Empty; PanelHandle.Style[HtmlTextWriterStyle.Cursor] = "Default"; HeaderContainer.Style[HtmlTextWriterStyle.MarginLeft] = "5px"; HeaderTable.Rows[0].Cells.Remove(ToolbarLeft); HeaderTable.Rows[0].Cells.Remove(ToolbarRight); BodyTable.Rows.Remove(ToolbarBottom); ToolbarMiddle.Style[HtmlTextWriterStyle.BackgroundImage] = string.Empty; ToolbarMiddle.Style["background-repeat"] = string.Empty; ToolbarBottomCell.Style[HtmlTextWriterStyle.BackgroundImage] = string.Empty; ToolbarBottomCell.Style["background-repeat"] = string.Empty; } } };usercontrol complex properties declarative syntax UserControl TemplateControlParser user control user control content user control property template user controls UserControls user interface WebUserControl
Nai-Dong Jin...
All-Star
41630 Points
3558 Posts
Re: UserControl ITemplate Property Design Time Error - Easy for a Guru...
Jul 23, 2008 03:28 AM|LINK
Hi,
You need to add two more attributes in your user control class level and the property level.
[
Other attributes,
ParseChildren(true, "Header"),Other attributes
]
public partial class WucCollapsibleSectionBox : System.Web.UI.UserControl, INamingContainer {
private ITemplate m_headerTemplate;
private ITemplate m_contentTemplate;
… …
[
Other attributes,
PersistenceMode(PersistenceMode.InnerDefaultProperty),Other attributes
]
public ITemplate Header {
get { return m_headerTemplate; }
set { m_headerTemplate = value; }
}
Thanks.
Nai-Dong Jin...
All-Star
41630 Points
3558 Posts
Re: UserControl ITemplate Property Design Time Error - Easy for a Guru...
Jul 24, 2008 09:37 AM|LINK
Hi,
Currently I am marking this thread as “Answered”, if my reply does not help you resolve the problem, please feel free to unmark it. Please also provide the following information and we will be glad to follow up.
The error message after you tried the solution above.
Thanks.
gangelo
Member
596 Points
272 Posts
Re: UserControl ITemplate Property Design Time Error - Easy for a Guru...
Jul 24, 2008 06:12 PM|LINK
It did not work.
I am getting the following design-time error:
Error Rending Control - Control Name
Type 'System.Web.UI.UserControl' does not have a public property named 'Header'.
Just curious, why does it reference "UserControl" and not the name of my UserControl derived class?
gangelo
Member
596 Points
272 Posts
Re: UserControl ITemplate Property Design Time Error - Easy for a Guru...
Jul 28, 2008 12:07 PM|LINK
I need an answer on this PLEASE!!!!!!!!
gangelo
Member
596 Points
272 Posts
Re: UserControl ITemplate Property Design Time Error - Easy for a Guru...
Jul 29, 2008 02:11 PM|LINK
I NEED AN ANSWER! PLEASE!!!!!!!
mikimyky
Member
2 Points
1 Post
Re: UserControl ITemplate Property Design Time Error - Easy for a Guru...
Mar 20, 2009 08:23 AM|LINK
gangelo
Member
596 Points
272 Posts
Re: UserControl ITemplate Property Design Time Error - Easy for a Guru...
Mar 23, 2009 02:41 PM|LINK
Simply amazing that noone from Microsoft can address this [:@]
mr_squall
Member
17 Points
13 Posts
Re: UserControl ITemplate Property Design Time Error - Easy for a Guru...
Oct 29, 2009 12:55 PM|LINK
Sorry! But this solution not worked for me too? How to create container control fro designer?
JP.Pinho
Member
2 Points
1 Post
Re: UserControl ITemplate Property Design Time Error - Easy for a Guru...
Jun 30, 2010 08:34 PM|LINK
Just to elarge the frustrated list, here are my thoughts...
I'm passing through this problem too.. And now it would be thankfull to receive an answer from
Microsoft Allmighty ASP.NET Developers, so my question is:
You guys sat someday talking about ASP.NET and how to develop a solid control encapsulated with
design time support (because people were no really used to write HTML that new thing that makes the
web look nice) and so you decided to wrote a WebControl deriving the Control class... so far so good,
but because some reason nobody thought or i think that nobody thought, shouldn't we develop a designer
for it ?! i bet some nerd must have said for what? you can do everything through code... but then after that
you looked and thought, oh we need a designer to drag this we developed into... so you developed a designer
were we can write HTML and drag&drop WebControls. With age we gained some maturity and we start combining
and templating and composing, and thats when you guys once again released new concepts like, templates throught
grid and details views and list views etc... and Composite Web Control etc etc.. and USER CONTROLS.. now reading
from the beginning again it pops the question, why didn't you guys developed UserControl right from the start insted
of a blind Server Control??!
I'm an Arquitect i understand, we have timmings and we lack a crystal ball ok accepted! but now that you, your clients and
the frustated social groups that talk about it, know that user controls seems to be the way, and just because it is so close to
being there why doesn't some body tells us how can we correct this unexpected behaviour??
Can Microsoft develop an hotfix and update??!!?! something
..... need help... no time... ask participation i'm sure every body in this forum agree to write a piece of code if that is what is
required to use usercontrols and gain much more in productivity...
but the final question is: How can we correct the Designer error when using ITemplates inside UserControls on the Designer,
eg:
<PhenomenalUC runat="server">
<MegaTemplate>
some text.... some binding etc
</MegaTemplate>
</PhenomenalUC>
Thanks,
JP