Stopping automatic declaration in code behind class

D

Dhiman

Here is the problem.

I have a parant class where I have declared couple of variables for user control that I will be using in the web pages. (ParentPage.vb)
This class is inherited by the code behind class. (WebPage.aspx.vb : Inherits ParentPage.vb)
In the aspx I have placed the user controls. (WebPage.aspx)

I'm using Visual Studio.NET and it automatically declares the those user controls in WebPage.aspx.vb.

Can I stop it somehow.

I had taken the following steps to no avail - Placed the user control directly into the template of WebForm and then used the template to create WebPage.aspx. This seemed to work, because when I switched from design to HTML view .. the declaration were not placed. However, when I closed and reopened the solution - the variables were declared! :(

Thanks in advance
Dhiman
 
N

Natty Gur

Hi,

If I understood you correctly the declared variable in your base page
collide with automatic declaration of user control on derived pages.
You can:
1) Just declare user control on your base page and use findcontrol to
point your user control variable to actual control on derived page.
2) Dynamic load user controls on derived page:
http://www.aspfree.com/c/a/ASP.NET/Dynamically-Loading-User-Controls-in-
ASPNET/

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top