Wednesday, March 21, 2012

Passing a UserControl as a parameter in ASP.NET 2

I have a few user controls which I would like to pass to a function which is not on the page the usercontrols have been placed in.

The function is in the App_Code directory so I can access it from anywhere in the project but I can't refer to the user control in the parameters of the function, therefore I can't access the usercontrol.

I'm not allowed to place the UserControl in the App_Code directory, so how can I create an instance of it?

Do you have control of the server where the app is going to be deployed ?

ie is it for an in house development or are you going to upload it to a public server ?

i ask coz if you have control of the server one way around the problem is to

make a dll (class) and by putting the code in the class your program will be able to access the code

Mark
Thanks Mark, will do that by building a dll. Only thing is I'm surprised that there is no way to do this using the ASP.NET 2 development model - the App_Code directory was supposed to replace the procedure of building and referencing dll's.

0 comments:

Post a Comment