Skinable web forms

  • Thread starter Thread starter SOS
  • Start date Start date
S

SOS

Hi ,
i am trying to write a skinable web site.
i created several user controls for variuos operations such as login , page
navigation and etc.
how can i load some "custom controls" in these "user controls" ?
i use of Page.LoadControl method on these user controls but i get this error
: "object reference not set to an instacne ..."
what's the problem ?

Thanx
 
I can see what you are trying to do

According to msdn help, the 'LoadControl' method takes (string virtualPath) as the arguement. And the 'virtualPath' specified the 'virtual path to a user control file

That means you cannot load 'custom control' that way

You can try doing something like this (in your user controls)
MyCustomControl mcc = new MyCustomControl()

You can also consider using Rendered Custom Controls, which you can programmatically stream out html.

HTH
 
Interesting fact...
LoadControl worked well for me
(Page.LoadControl("~/subfolders/UserControl.ascx"),
but when I tried programmatically add it like this
dim ucMyUserControl as UserControl
ucMyUserControl = new UserControl
I got "reference to null" error...
How come?
So what's the way to create/load UC dynamically according to language
reference? Thanks.

--
With the best wishes,
Shaul Feldman

one said:
I can see what you are trying to do.

According to msdn help, the 'LoadControl' method takes (string
virtualPath) as the arguement. And the 'virtualPath' specified the 'virtual
path to a user control file'
That means you cannot load 'custom control' that way.

You can try doing something like this (in your user controls):
MyCustomControl mcc = new MyCustomControl();

You can also consider using Rendered Custom Controls, which you can
programmatically stream out html.
 
Back
Top