We help IT Professionals succeed at work.

Wrap the class declaration in a namespace declaration

Alan Warren
Alan Warren asked
Last Modified: 2008-04-24
Hi all...
Started learning .Net, having heaps of fun with Visual Web Developer Express and SQL Express.

Been working through some online tutorials for Visual Web Developer Express, currently doing this one:

In steps 6 and 7 I have encountered something I do not understand. I'm sure it is simple, but I need help to understand it.

6. In the Solution Explorer, right-click app_code and select Add New Item. Add a new Class file named "PageBase" (followed by the extension of the language you are using, whether .cs, .vb or .js).

Wrap the class declaration in a "GeekSpeak" namespace declaration.    <== what does this mean?????

7. Derive the class from Page and then add the following code to the class (in C#, make sure your public class looks like: "public class PageBase : System.Web.UI.Page" and that you add "namespace GeekSpeak" just above the Public class declaration):  <== what does it mean "Derive the class from the page" ????

Alan ";0)
Watch Question

This one is on us!
(Get your first solution completely free - no credit card required)
Alan WarrenApplications Developer


Hi fareed,
thanks for the comment.

I forgot to mention my page language is VB, this is the class module in app_code/PageBase.vb

Imports Microsoft.VisualBasic
Public Class PageBase
  ' Do stuff    
End Class

Alan WarrenApplications Developer


Ok, think I have it sorted out now, thanks for your help.

Found a discussion on NameSpace declarations here:
Creating Your own Namespace...

Imports Microsoft.VisualBasic

Namespace GeekSpeak    ' <== wrap class in NameSpace
    Public Class PageBase
        Inherits System.Web.UI.Page   '<== Inherit from the page

        Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
            If IsNothing(Session("UserName")) AndAlso User.Identity.IsAuthenticated Then
                Session("UserName") = User.Identity.Name
            End If

            If Not IsNothing(Session("Theme")) Then
                Dim ThemesDropDownList As DropDownList = _
                    CType(Page.Master.FindControl("themesDropDownList"), DropDownList)

                ThemesDropDownList.SelectedValue = Session("Theme").ToString()
                Page.Theme = ThemesDropDownList.SelectedValue
                Page.Theme = "Arctic Ice"
            End If
        End Sub

    End Class
End Namespace

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.