|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Web user controlHi,
I just started with .Net 2.0 and have created a few user controls that I would like now to use in my webpage. I need to create them in my onload and add them into a table on the aspx page. I am using C#. My proble is that I get exception "Use the "new" keyword to create an object of instance" "Check to determin if the object is null before calling the method". It seems to me that InitializeComponents() method has not executed and all labels, buttons and dropdown list in my component has value null.. Any Idea how to create instance of my components dynamically and show them in a aspx page??? -- LZ Hi,
you basically cannot instantiate user control with new keyword, since that would instantiate only UC's code-behind class if any. The markup side would not be parsed and associated with the instance. Instead, use Control c = Page.LoadControl("control.ascx"); Show quote "Lamis" <La***@discussions.microsoft.com> wrote in message news:3A8AC869-64DF-42EC-8912-031B1220354E@microsoft.com... > Hi, > I just started with .Net 2.0 and have created a few user controls that I > would like now to use in my webpage. I need to create them in my onload > and > add them into a table on the aspx page. I am using C#. My proble is that I > get exception "Use the "new" keyword to create an object of instance" > "Check > to determin if the object is null before calling the method". > It seems to me that InitializeComponents() method has not executed and all > labels, buttons and dropdown list in my component has value null.. > Any Idea how to create instance of my components dynamically and show them > in a aspx page??? > > -- > LZ |
|||||||||||||||||||||||