T
tshad
I have a .ascx file that I converted to a class.
But I am getting the following error:
error BC30469: Reference to a non-shared member requires an object
reference.
The error is for the Page.FindControl in the following code:
******************************************
Imports System
Imports System.Web
Imports System.IO
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.SessionState
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.HttpCookie
Imports System.Web.HttpCookieCollection
Imports System.Web.HttpResponse
Imports System.Web.HttpRequest
imports System.Web.HttpContext
Imports System.Web.HttpApplication
Imports System.Web.HttpApplicationState
Imports System.Collections
NameSpace MyFunctions
Public Class PageInit
Public Shared sub PageSetup ()
Dim UserLoggedOn as Label = CType(Page.FindControl("UserLoggedOn"),Label)
Dim UserLoggedOnLabel as Label =
CType(Page.FindControl("UserLoggedOnLabel"),Label)
if not UserLoggedOn is nothing then
if HttpContext.Current.session("LoggedIn") <> nothing then
if HttpContext.Current.session("firstName") <> nothing then
UserLoggedOn.Text = UserLoggedOn.Text &
HttpContext.Current.session("firstName")
if HttpContext.Current.session("lastName") <> nothing then
UserLoggedOn.Text = UserLoggedOn.Text & " " &
HttpContext.Current.session("lastName")
end if
end if
if not UserLoggedOn is nothing then
UserLoggedOn.visible = true
if not UserLoggedOnLabel is nothing then UserLoggedOnLabel.visible =
true
end if
end if
end if
if not HttpContext.Current.session("User") is nothing then _
HttpContext.Current.session("LastPageVisited") =
HttpContext.Current.Session("User").LastPageVisited
End Sub
End Class
End Namespace
*************************************************************************
Why am I getting this error?
Do I need something in front the Page.FindControl?
Thanks,
Tom
But I am getting the following error:
error BC30469: Reference to a non-shared member requires an object
reference.
The error is for the Page.FindControl in the following code:
******************************************
Imports System
Imports System.Web
Imports System.IO
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.SessionState
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.HttpCookie
Imports System.Web.HttpCookieCollection
Imports System.Web.HttpResponse
Imports System.Web.HttpRequest
imports System.Web.HttpContext
Imports System.Web.HttpApplication
Imports System.Web.HttpApplicationState
Imports System.Collections
NameSpace MyFunctions
Public Class PageInit
Public Shared sub PageSetup ()
Dim UserLoggedOn as Label = CType(Page.FindControl("UserLoggedOn"),Label)
Dim UserLoggedOnLabel as Label =
CType(Page.FindControl("UserLoggedOnLabel"),Label)
if not UserLoggedOn is nothing then
if HttpContext.Current.session("LoggedIn") <> nothing then
if HttpContext.Current.session("firstName") <> nothing then
UserLoggedOn.Text = UserLoggedOn.Text &
HttpContext.Current.session("firstName")
if HttpContext.Current.session("lastName") <> nothing then
UserLoggedOn.Text = UserLoggedOn.Text & " " &
HttpContext.Current.session("lastName")
end if
end if
if not UserLoggedOn is nothing then
UserLoggedOn.visible = true
if not UserLoggedOnLabel is nothing then UserLoggedOnLabel.visible =
true
end if
end if
end if
if not HttpContext.Current.session("User") is nothing then _
HttpContext.Current.session("LastPageVisited") =
HttpContext.Current.Session("User").LastPageVisited
End Sub
End Class
End Namespace
*************************************************************************
Why am I getting this error?
Do I need something in front the Page.FindControl?
Thanks,
Tom