473,396 Members | 2,023 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Page.FindControl not working

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").LastPageVisite d
End Sub
End Class
End Namespace
************************************************** ***********************

Why am I getting this error?

Do I need something in front the Page.FindControl?

Thanks,

Tom

Aug 16 '06 #1
0 1176

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Kevin Phifer | last post by:
Ok, before anyone freaks out, I have a solution I need to create that gathers content from maybe different places. Each one can return a <form> in the html, so its the classic can't have more than...
1
by: Michael Murschell | last post by:
If I call Page.FindControl() on an aspx, it finds the control, but if I call it on an ASCX, it does not. Why not? And how would I call it?
2
by: sck10 | last post by:
Hello, I am looping through each control using the following to find a particular control (strFindCtl = "tbxCompetitor" & strForLoop1 & "Product"). For ctrRow = 1 To 3 strForLoop1 = "0" &...
5
by: Howard | last post by:
i have a default.master and default.aspx in default.aspx i would like to access a variable in default.master pageTitle public partial class _Default : System.Web.UI.Page { protected void...
9
by: D. Shane Fowlkes | last post by:
(ASP.NET 2 / VB) Question - How can I write a If statement to see if a control (textbox) actually exists on a page? Upon page_load, a certain control may or may not be visible on the page so I...
3
by: tshad | last post by:
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...
5
by: daniel.hedz | last post by:
I am generating a usercontrol dynamically successfully, but when I try to find that usercontrol I get a type mismatch. This is what I am doing: //Loading my usercontrol...
2
by: jpavel | last post by:
Hello everyone. I'm having a problem with accessing components. I've looked for a solution in other forums but until now no one have given me any tiny clue about how could I solve it. I know there...
2
by: pankajsingh5k | last post by:
Dear All, Please help me... I had read an article to lazy load a tab in a tabcontainer using an update panel on http://mattberseth.com/blog/2007/07/how_to_lazyload_tabpanels_with.html ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.