Session problem (I think)

WillBoss

Member
Joined
May 31, 2006
Messages
8
Programming Experience
Beginner
Hi
I am new to programming and playing around with Visual Studio at the moment.
I have created mini CMS which writes the actual body of the html to a dayabase. Now I have decided that I want to have a defferent Masterpage for different categories. This is where my problem begins. I am having trouble assigning the different Masterpage templates to the categories. I am using the code below in my index.apsx page:
VB.NET:
Protected Overrides Sub OnPreInit(ByVal e As EventArgs)
        If Session("PageName") IsNot Nothing Then
            'Checking Pages for MasterPage match
            Select Case Session("PageName").ToString.ToLower
                Case "contact information"
                    Me.MasterPageFile = "MasterPageGray.master"
                    MyBase.OnPreInit(e)
                Case "contact us"
                    Me.MasterPageFile = "MasterPageGray.master"
                    MyBase.OnPreInit(e)
                Case "hardware systems"
                    Me.MasterPageFile = "MasterPageRed.master"
                    MyBase.OnPreInit(e)
            End Select
 
        Else
            Me.MasterPageFile = "MasterPageGray.master"
            MyBase.OnPreInit(e)
        End If
    End Sub
Now the default Masterpage is Masterpage.master and this is being changed in the 'Else' statement. So I know I can actually change the Masterpage. I am sure this is a session problem but as I am fairly new to this lark I am not sure how to solve the problem. Is there any way I can display the actual session name to the page for testing purposes so I can see what the hell is going on?
Any help would be appreciated.
Regards
Will
 
Ok, I figured out how to dosplay the session name to the screen and guess what I am displaying a blank.
VB.NET:
Response.Write(("This is the session variable") + Session("PageName"))

Any suggestions?
 
Back
Top