changing page control protection level

G

Guest

Hi

I'm developing an ASP.NET app in Visual studio (using C# for code behind). My question is fairly simple (i think). When I go to the code behind page, the controls in the html page are made "protected" so that it can only be accessed from within that page.

I would like to permanently make this "public" for certain controls, so that I can access them from another page (the page that a user control is embedded into for example). If I manually change it, it is fine but when I change something on the HTML page for a control, it reverts back to "protected". It's a real pain continually changing this back to "public", especially since I have quite a few user controls now. I'm assuming that it is Visual Studio that is implementing this annoying quirk. Any help would be appreciated

Regards,
 
J

Jason DeFontes

You should create public properties in you code behind class that expose
the controls you want:

protected Control someControl;

public Control SomeControl
{
get { return someControl; }
}

VS won't mess with the properties you declare yourself, and then you
don't have to worry about it changing the protection level of the
controls that it creates.

-Jason
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top