heya,
i'm taking my first stab at implementing custom controls in a web app and i keep getting errors (surprise surprise) while trying to build instances of custom controls. first off, these are not User Controls, rather, i'm creating a class heirarchy starting with an abstract prototype and instantiating derived child instances.
for example, here's a sample implementation...
as far as i know, all i need to do is add a directive to the top of the aspx doc and an accompanying tag to the doc as well. like
in my class code (which inherits from System.Web.UI.WebControls.WebControl), i'm defining a few protected fields for various UI widgets (labels, textbxs, etc). instances of these members are created within a custom InitializeComponent call via the constructor and then added to a local arrayList. lastly..., the CreateChildControls method (which i believe is called during the actual building) adds the elements of the arrayList to the objects Controls collection, e.g...
unfortunately, i can't seem to get a single instance of any custom control to be built. design-time shows an immediate error ("Error Building Control: instanceName"
in HTML view, and errors are simply returned in the browser on execute.
am i missing a key step here or the concept as a whole or...? any help/advice is greatly appreciated. thanks!
mirirom
i'm taking my first stab at implementing custom controls in a web app and i keep getting errors (surprise surprise) while trying to build instances of custom controls. first off, these are not User Controls, rather, i'm creating a class heirarchy starting with an abstract prototype and instantiating derived child instances.
for example, here's a sample implementation...
Code:
{documentType:abstract}
||
______________||____________
| |
{transmittalType:public} {meetingLogType:public}
as far as i know, all i need to do is add a directive to the top of the aspx doc and an accompanying tag to the doc as well. like
Code:
<%@ TagPrefix="dt" Namespace="AppFoo.codeBin" Assembly="AppFoo"%>
...
<dt:someInstance id="bar" runat="server" />
in my class code (which inherits from System.Web.UI.WebControls.WebControl), i'm defining a few protected fields for various UI widgets (labels, textbxs, etc). instances of these members are created within a custom InitializeComponent call via the constructor and then added to a local arrayList. lastly..., the CreateChildControls method (which i believe is called during the actual building) adds the elements of the arrayList to the objects Controls collection, e.g...
Code:
this.Controls.Clear();
foreach(WebControl wc in arlLocalCtls)
{this.Controls.Add(wc);}
unfortunately, i can't seem to get a single instance of any custom control to be built. design-time shows an immediate error ("Error Building Control: instanceName"
am i missing a key step here or the concept as a whole or...? any help/advice is greatly appreciated. thanks!
mirirom