Web controls declarations in base class

C

Chris

This may be more of a Visual Studio question but those groups seem to
be full of unrelated stuff so hopefully this might be the right place.

I have a class (no associated aspx file) which handles all the common
startup code for the pages on our website. It is derived from
System.Web.UI.Page and every page in 2 separate projects (web
applications) derives from it. It contains several declarations of
server controls such a navigation bar that are common to all pages.

My problem is that when I open a webform that derives from the shared
base class, Visual Studio inserts declarations for the nav bar and
other controls into the code behind file for that webform even though
it derives from the base class which declares the controls itself,
hiding the underlying declaration. So at runtime when I try to acces
the controls in the start up code they are set to null because the
control in the .aspx page is not linked with the correct declaration.

It's annoying having to delete the declarations every time I open the
webform. How can I stop this or get visual studio to recognise the
underlying declarations? The declarations are all protected and I'm
using C# in Visual Studio 7.1.3038
 
J

John Saunders

Chris said:
My problem is that when I open a webform that derives from the shared
base class, Visual Studio inserts declarations for the nav bar and
other controls into the code behind file for that webform even though
it derives from the base class which declares the controls itself,
hiding the underlying declaration. So at runtime when I try to acces
the controls in the start up code they are set to null because the
control in the .aspx page is not linked with the correct declaration.

Sorry, that's known behavior. VS.NET 2002/2003 weren't meant to deal with
"visual inheritance" in Web Forms like you have in Windows Forms.

John Saunders
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top