Ask a Question related to ASP.NET General, Design and Development.
-
Salek Talangi #1
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.WebControls.Label
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.HLabel.Text = "Hello World"
This (and any try with "new") gives me the error:
"System.NullReferenceException: Object reference not set
to an instance of an object."
Any help is appreciated
Thanks in advance,
Salek
Salek Talangi Guest
-
#25377 [Bgs]: Class variables can be added out of class definition
ID: 25377 Updated by: helly@php.net Reported By: forseti at oak dot rpg dot pl Status: Bogus Bug Type: ... -
Instance- and class-variables (was mixing in class methods)
Hi -- On Thu, 2 Oct 2003, Mark J. Reed wrote: Also, every object should have the right to maintain state in instance variables that are... -
Instance- and class-variables (was mixing in class methods)
Hi -- On Fri, 3 Oct 2003 dblack@superlink.net wrote: And of course the fact that it might actually be self.class.class_eval { @var } also... -
Instance- and class-variables (was mixing in class methods)
Hi -- On Thu, 2 Oct 2003, Gavin Sinclair wrote: Ummm, what array? :-) I think you'd need something like: class Project class << self... -
Accessing page request / server variables in a class file.
Hi, Here's a question for you all. Under "classic" ASP any ASP page could have any number of #Include files. Using #Include files I could have... -
Kevin Spencer #2
Re: Accessing variables of another class
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
[url]http://www.takempis.com[/url]
Big things are made up of
lots of little things.
"Salek Talangi" <blama@gmx.net> wrote in message
news:071601c35509$5b111a60$a401280a@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.WebControls.Label
>
> 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.HLabel.Text = "Hello World"
>
> This (and any try with "new") gives me the error:
> "System.NullReferenceException: Object reference not set
> to an instance of an object."
>
> Any help is appreciated
>
> Thanks in advance,
> Salek
>
>
Kevin Spencer Guest



Reply With Quote

