473,657 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing variables of another class

Hello,
I have following (probably very basic) problem:
I made a html-frameset in VS.net, where the frames
itself are aspx-pages with webforms.
Now I want to access the webforms (eg. give a label a
text) from one .aspx.vb page.
I managed to get all the code into one file by writing
the same file in the codebehind statement of all aspx
files.
Now I have one big .aspx.vb file with:
Public Class Header
Public Class Main

There is a Label in the header.aspx and its defined
in header-class as
Public WithEvents HLabel As System.Web.UI.W ebControls.Labe l

How do I access this Label from my Main Class? It has to
be possible, but I failed.

I tried this, but it didn't work:
Dim theHeader As Header = New Header()
theHeader.HLabe l.Text = "Hello World"

This (and any try with "new") gives me the error:
"System.NullRef erenceException : Object reference not set
to an instance of an object."

Any help is appreciated

Thanks in advance,
Salek
Nov 17 '05 #1
1 2132
In order to access a member of a non-shared class, you must obtain a
reference to an instance of that class. You have a couple of problems to
deal with here, and what sounds to me like a misconception that needs to be
straightened out. ASP.Net Pages have 2 components which never meet, but only
send messages back and forth to each other: The client-side HTML and the
server-side Class. They only SEEM to be connected. Now, you're dealing with
a frameset here, but you need to understand that the server-side elements of
these pages will never be able to see each other, as they exist for a brief
time at different times on the server, each while a request for that Page is
being processed. On the client, the 2 pages (client-side HTML) exist in the
same frameset, and for a much longer time (basically, while both pages are
loaded in the frameset, and neither one is being posted back to the server).
The only way to have these pages communicate is on the client-side, via
JavaScript. So, you will need to use JavaScript to access the HTML objects
in one page from the other page.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big things are made up of
lots of little things.

"Salek Talangi" <bl***@gmx.ne t> wrote in message
news:07******** *************** *****@phx.gbl.. .
Hello,
I have following (probably very basic) problem:
I made a html-frameset in VS.net, where the frames
itself are aspx-pages with webforms.
Now I want to access the webforms (eg. give a label a
text) from one .aspx.vb page.
I managed to get all the code into one file by writing
the same file in the codebehind statement of all aspx
files.
Now I have one big .aspx.vb file with:
Public Class Header
Public Class Main

There is a Label in the header.aspx and its defined
in header-class as
Public WithEvents HLabel As System.Web.UI.W ebControls.Labe l

How do I access this Label from my Main Class? It has to
be possible, but I failed.

I tried this, but it didn't work:
Dim theHeader As Header = New Header()
theHeader.HLabe l.Text = "Hello World"

This (and any try with "new") gives me the error:
"System.NullRef erenceException : Object reference not set
to an instance of an object."

Any help is appreciated

Thanks in advance,
Salek

Nov 17 '05 #2

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

Similar topics

4
3387
by: keepyourstupidspam | last post by:
Hello, I have a class X with a member function setConfigValues(). I want to access this member function in another class Y. Y is not inherited from X. A member function of class X called run() this instanciates the class Y. Class X { run();
9
5395
by: Bob Day | last post by:
VS 2003, vb.net , sql msde... I have an application with multiple threads running. Its a telephony application where each thread represents a telephone line. For code that would be the same for each thread, I put in Shared methods as below. It is only now that I am realizing the complexity of multiple threads accessing shared methods. And, quite honestly, I am very confused. I have tried System.Threading.Monitor.Enter, Synclock,...
8
2736
by: dwok | last post by:
I have been wondering this for a while now. Suppose I have a class that contains some private member variables. How should I access the variables throughout the class? Should I use properties that expose the variables or is it OK to just access the variables directly? Keep in mind that I am talking about accessing the variables from within the class that they are defined. Thanks!
5
2697
by: Cyril Gupta | last post by:
Hello, I have a class inside another class. The Scenario is like Car->Engine, where Car is a class with a set of properties and methods and Engine is another class inside it with its own set of properties. I want to know if there is a way to access the methods and the properties of the Owner class for the class that's inside it? I.e. I want to find out within Engine what make the Car is which is exposed by the property Car.Model.
2
2346
by: Jurek Dabrowski | last post by:
hi all, I have a question in reference to accessing variables in another class maybe someone has dealt with before. I have some public variables declared in my main plug-in class CCommandMeshToSrf, eg: BOOL m_bHaveAnswer; I want to set this variable from within a dialog class which is defined in separate .h and .cpp files of course. How would one access this varibale from a method defined in my CTestModelessDialog class ?
0
8825
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8605
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7327
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6164
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4152
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.