Stopping automatic declaration in code behind class

  • Thread starter Thread starter Dhiman
  • Start date Start date
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
 
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
 
Back
Top