VS Designer code change

G

Guest

Hello all,
When we add a new component in default.aspx in the designer mode, it
automitically adds a line declairing the component in the codebehind. We dont
want the declaration of this component in the code behind because we inherit
from a base class which already contain this declaration of the component.
For example, we need a "TopMenu" component in all pages so we declared it in
the Base Class. The base class will fill this menu...
My issue is that when I use the Design mode, VS adds the component
declarations in my code behind. So I have the declaration twice (code behind
& base class) and this two declaration makes conflict.
Do you have any idea to create a base class & use the design mode without
having this conflic?
Thanks.
 
S

Steven Cheng[MSFT]

Hi Julien,

Welcome to ASPNET newsgroup.
From your description, you've define a base page class for your asp.net web
site and other pages will derive their codebehind page class from that base
one. Also, you've defined an component object reference as member in the
base class. However, when you add such a component in the derived page's
design-view, you found the VS.NET IDE will always add a new reference
member variable in the derived class rather than associate the component
with the reference in base class, yes?

As for this problem, I'm afraid it is due to the existing limitation on
ASP.NET Web form's page inheritance. The current ASP.NET web page's
inheritance is just simple codebehind class's inheritance on language
layer. It is not the actual Visutal inheritance like the winform's form
inheritance. So when we add new components or controls in ASP.NET page's
design-view in VS.NET IDE, the IDE has no idea of the existing component or
contorl reference in parent codebehind page class, it'll always add
reference member in the derived page class's code.

In ASP.NET 2.0, the MasterPage feature provide the complete Webform Visual
Inheritance that can help us add components or controls in MasterPage.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html
/masterpages.asp

Thanks,


Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

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

Similar Threads


Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,278
Latest member
BuzzDefenderpro

Latest Threads

Top