is an article explaining how/why to extend the Page class to bring a core group of properties and methods to all pages within an existing web app. I'm looking to clarify & verify my understanding of the article.
Each page of my web app hits a db so each page has a connection object. Currently each page declares:
Public connStr As String = ConfigurationSettings.AppS
Most pages have a drop down box declared via:
Protected WithEvents ddModule As System.Web.UI.WebControls.
that is created by a Function:
Function CreateModules() As ICollection
ddModule.Items.Add(New ListItem("First Item", "table1"))
ddModule.Items.Add(New ListItem("Second Item", "table2"))
ddModule.Items.Add(New ListItem("Third Item", "table3"))
The page_Load event on each page checks a session var to see if an alternative connection string should be used.
If Session("uID") = 10162 Then
connStr = ConfigurationSettings.AppS
All these constructs would be better placed in a class that extends ASP.NET's Page class, yes?
Now to clarify the implementation:
The article includes 2 methods of adding this class to the project.
If you are using Visual Studio .NET, the base class can be added to your ASP.NET project in one of two ways. The simplest option is to add a Class File to your ASP.NET project. To do this, right-click on the folder you want to add your project in the VS.NET Solution Explorer and choose to Add and then Add Class.
A better approach, in my opinion, is to add a new Class Library project to the Solution. To do this, right-click on the Solution in the Solution Explorer, select Add and choose New Project. Add a New Project of type Class Library in your language of choice. You can then add your base class to this new project. Finally, be sure to add a Reference from the Web application to the Class Library project by right-clicking on the Web application's References folder, selecting Add Reference. From the Add References dialog box, select the Projects tab and then add the Class Library project you just created.
I'm not well versed in controlling/configuring VS and would like the above spelled out in a bit more detail.