My problem:
I'm writing a "codeBehind" page that makes reference to a Session variable and when I run the page I get - "Type Session is not defined". Now, I think what I need to do is to import the namespace which contains the Session object however after about an hour of searching the class browser I have not been able to find that namespace.
1)Can anyone tell me where in the namespace I might find the Session object?
2)Are there any good utilities to search the namespace for a given object to see where it resides?
thanks much
DogYou should not need to import a namespace, and I do not believe there is even one to import.surely with 9000 posts you've seen this line of logic.
Imports System
Imports System.DateTime
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.UserControl
Namespace myNameSpace
Public Class navBarCodeBehind : Inherits UserControl
Public lnkTeams As Hyperlink
Public lnkPlayers As Hyperlink
Public lnkGames As Hyperlink
Public lnkResults As Hyperlink
Public lnkChat As Hyperlink
Public ddlTheme As DropDownList
Public btnApplyTheme As Button
Public chkRemeberStylePref As Checkbox
'btnApplyTheme_Click applies different css sheet to the page
Sub btnApplyTheme_Click(sender As Object, e As EventArgs)
Session("SelectedCss") = ddlTheme.SelectedItem.Value
If ChkRemeberStylePref.Checked Then
Dim CssCookie As New HttpCookie("PreferredCss")
CssCookie.Value = ddlTheme.SelectedItem.Value
CssCookie.Expires = now.AddSeconds(20)
Response.Cookies.Add(CssCookie)
End If
End Sub
End Class
End NamespaceIf your button is a WebConrol it should be declared like this:
Public WithEvents btnApplyStyle as Button
And your sub should look like this:
Sub btnApplyStyle_Click(sender As Object, e As EventArgs) Handles btnApplyStyle.Click
' ----whatever code
End Sub
Good Luck!Originally posted by lcscne
surely with 9000 posts you've seen this line of logic.
Imports System
Imports System.DateTime
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.UserControl
Namespace myNameSpace
Public Class navBarCodeBehind : Inherits UserControl
Public lnkTeams As Hyperlink
Public lnkPlayers As Hyperlink
Public lnkGames As Hyperlink
Public lnkResults As Hyperlink
Public lnkChat As Hyperlink
Public ddlTheme As DropDownList
Public btnApplyTheme As Button
Public chkRemeberStylePref As Checkbox
'btnApplyTheme_Click applies different css sheet to the page
Sub btnApplyTheme_Click(sender As Object, e As EventArgs)
Session("SelectedCss") = ddlTheme.SelectedItem.Value
If ChkRemeberStylePref.Checked Then
Dim CssCookie As New HttpCookie("PreferredCss")
CssCookie.Value = ddlTheme.SelectedItem.Value
CssCookie.Expires = now.AddSeconds(20)
Response.Cookies.Add(CssCookie)
End If
End Sub
End Class
End Namespace
I misread your original post. But to use the session (just the session state) it would not be neccessay to import anything.
I'm writing a "codeBehind" page that makes reference to a Session variable and when I run the page I get - "Type Session is not defined". Now, I think what I need to do is to import the namespace which contains the Session object however after about an hour of searching the class browser I have not been able to find that namespace.
1)Can anyone tell me where in the namespace I might find the Session object?
2)Are there any good utilities to search the namespace for a given object to see where it resides?
thanks much
DogYou should not need to import a namespace, and I do not believe there is even one to import.surely with 9000 posts you've seen this line of logic.
Imports System
Imports System.DateTime
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.UserControl
Namespace myNameSpace
Public Class navBarCodeBehind : Inherits UserControl
Public lnkTeams As Hyperlink
Public lnkPlayers As Hyperlink
Public lnkGames As Hyperlink
Public lnkResults As Hyperlink
Public lnkChat As Hyperlink
Public ddlTheme As DropDownList
Public btnApplyTheme As Button
Public chkRemeberStylePref As Checkbox
'btnApplyTheme_Click applies different css sheet to the page
Sub btnApplyTheme_Click(sender As Object, e As EventArgs)
Session("SelectedCss") = ddlTheme.SelectedItem.Value
If ChkRemeberStylePref.Checked Then
Dim CssCookie As New HttpCookie("PreferredCss")
CssCookie.Value = ddlTheme.SelectedItem.Value
CssCookie.Expires = now.AddSeconds(20)
Response.Cookies.Add(CssCookie)
End If
End Sub
End Class
End NamespaceIf your button is a WebConrol it should be declared like this:
Public WithEvents btnApplyStyle as Button
And your sub should look like this:
Sub btnApplyStyle_Click(sender As Object, e As EventArgs) Handles btnApplyStyle.Click
' ----whatever code
End Sub
Good Luck!Originally posted by lcscne
surely with 9000 posts you've seen this line of logic.
Imports System
Imports System.DateTime
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.UserControl
Namespace myNameSpace
Public Class navBarCodeBehind : Inherits UserControl
Public lnkTeams As Hyperlink
Public lnkPlayers As Hyperlink
Public lnkGames As Hyperlink
Public lnkResults As Hyperlink
Public lnkChat As Hyperlink
Public ddlTheme As DropDownList
Public btnApplyTheme As Button
Public chkRemeberStylePref As Checkbox
'btnApplyTheme_Click applies different css sheet to the page
Sub btnApplyTheme_Click(sender As Object, e As EventArgs)
Session("SelectedCss") = ddlTheme.SelectedItem.Value
If ChkRemeberStylePref.Checked Then
Dim CssCookie As New HttpCookie("PreferredCss")
CssCookie.Value = ddlTheme.SelectedItem.Value
CssCookie.Expires = now.AddSeconds(20)
Response.Cookies.Add(CssCookie)
End If
End Sub
End Class
End Namespace
I misread your original post. But to use the session (just the session state) it would not be neccessay to import anything.