Groups | Blog | Home
all groups > asp.net building controls > november 2006 >

asp.net building controls : Error Creating Control - No parameterless constructor defined for this object


Nathan Sokalski
11/20/2006 10:10:49 PM
I have created a custom control for ASP.NET using VB.NET. My control =
inherits from the System.Web.UI.WebControls.CompositeControl class, and =
is working fine. However, the Visual Studio .NET designer shows the =
following error on the control in the designer:

Error Creating Control - No parameterless constructor defined for this =
object

I have defined four New methods. Although none of them are simply Public =
Sub New(), one of them has just one parameter which is optional. I would =
think that this would cover the requirement of having a parameterless =
constructor, since it can be called with no parameters. However, the =
designer doesn't seem to like it (although my control has run =
succesfully in all my test runs with no errors). When I try adding a =
parameterless constructor, I recieve an error in the code editor that =
mentions the overload that has a single optional parameter, which makes =
since because if it was called with no parameters there would be an =
ambiguity between them. What can I do about the error message in the =
designer? Thanks.



--=20
Nathan Sokalski
njsokalski@hotmail.com
Gaurav Vaish (www.EdujiniOnline.com)
11/21/2006 12:00:00 AM
Visual Studio does not know that the paramter is optional or what to =
provide in the paramters.
Explicitly have paramterless constructor.


--=20
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujinionline.com
http://eduzine.edujinionline.com
-----------------------------------------


[quoted text, click to view]
I have created a custom control for ASP.NET using VB.NET. My control =
inherits from the System.Web.UI.WebControls.CompositeControl class, and =
is working fine. However, the Visual Studio .NET designer shows the =
following error on the control in the designer:

Error Creating Control - No parameterless constructor defined for this =
object

I have defined four New methods. Although none of them are simply =
Public Sub New(), one of them has just one parameter which is optional. =
I would think that this would cover the requirement of having a =
parameterless constructor, since it can be called with no parameters. =
However, the designer doesn't seem to like it (although my control has =
run succesfully in all my test runs with no errors). When I try adding a =
parameterless constructor, I recieve an error in the code editor that =
mentions the overload that has a single optional parameter, which makes =
since because if it was called with no parameters there would be an =
ambiguity between them. What can I do about the error message in the =
designer? Thanks.



--=20
Nathan Sokalski
njsokalski@hotmail.com
AddThis Social Bookmark Button