Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Exposing A Control On A User Control
Message
From
03/04/2009 09:31:21
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, United States
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01392880
Message ID:
01392974
Views:
44
>I have created a user control which is a composite of other controls. It is possible to or how do I expose a control on my user control? In other words, I want to make a listbox on my control available in design and/or runtime.

Look in the *.aspx.designer.cs file of your user control. All of your controls should be declared in that file with a protected scope. You could cut them from that file and paste them into the *.aspx.cs file, and change the scope to public. If you change them to public in the *.aspx.designer.cs file you run the risk of having the entire file be automatically generated again overwriting your changes. I am doing this for a few controls and it works well.

Edit: Ignore the above response. The way to do this in ASP.NET is to create a public property in your *.aspx.cs file that points to the friend declaration in the *.aspx.designer.cs file.
Very fitting: http://xkcd.com/386/
Previous
Reply
Map
View

Click here to load this message in the networking platform