473,326 Members | 2,147 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,326 software developers and data experts.

Coming out of the closet - Object Reference - Knowing I most likely won't get an answer...


Hi Everyone

Here's a really simple and fundamental question for you boys and girls.
I'm quite embarrased asking it actually as I've ben programming for
four years now, always working my way around the issue, but thought of
finally coming out of the closet.

Question:
How do I manipulate (reference) an object on a form (.aspx) in ASP.NET
2.0 from a class? There are articles on how pass values between forms
etc etc but I really never figured that out which is really bad I
guess!

Sample:
I've a page called default.aspx with a ASP.NET 2.0 label control
And I've a class in the App_Code folder called clsLabel.vb

In the code-beside of default.aspx I'd like to put something like:
....
Label1.text = clsLabel.SetText()
....

While I've a Sub in clsLabel that sets the label text.
....
Label1.text = "Hello"
....

Note that this is a simple example and
I'd be grateful if you can please explain in plain English and
idiot-proof way.
Thank you for your help, infinite wisdom and efforts!

Martin

Mar 24 '06 #1
2 1066
On 24 Mar 2006 15:45:28 -0800, th************@hotmail.com wrote:
Question:
How do I manipulate (reference) an object on a form (.aspx) in ASP.NET
2.0 from a class? There are articles on how pass values between forms
etc etc but I really never figured that out which is really bad I
guess!


I think your premise is flawed. You shouldn't be trying to manipulate a
form from a middle tier class. That's the entire point of middle tier, to
seperate logic from presentation.

A form should call into your object to get it's data. The data should not
call into the form. Get the picture?
Mar 25 '06 #2
Thanks for your advice and thoughts Erik

Yes, that makes sense and admit that I actually have explained it
incorrectly.
The form calls indeed the class not the other way round. My intention
has been lost in simplifiying the issue.
What I really trying to do is have my form call a function in my class
and then return an object.
It's working know. Hope it's good practice the way I do it though?
Thank you very much for your time and efforts and for pointing me in
the right direction!

In aspx:

Dim clsFraMenu As New clsFraMenu
mnuLanguage = clsFraMenu.GetMnuLanguage(mnuLanguage)

In class:

Public Function GetMnuLanguage(ByVal objmnuLanguage As Menu) As Menu

Dim mnuLanguage As Menu = objmnuLanguage
....
Add menu items
....

Return mnuLanguage

End Function

Mar 25 '06 #3

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

Similar topics

28
by: Daniel | last post by:
Hello =) I have an object which contains a method that should execute every x ms. I can use setInterval inside the object construct like this - self.setInterval('ObjectName.methodName()',...
11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
30
by: jimjim | last post by:
Hello, This is a simple question for you all, I guess . int main(){ double *g= new double; *g = 9; delete g; cout<< sizeof(g)<<" "<<sizeof(double)<<" "<<sizeof(*g)<<" "<<*g<<" "<<endl; *g =...
8
by: Lee Jackson | last post by:
Whats the difference between the following in terms of how the CLR allocates and garbage collects? Which is better in terms of memory usage/performance? a) foreach (string strURL in...
8
by: Lance | last post by:
I've been teaching myself C# for a few months now and I have a concept problem. I know how to instantiate an object from a class I’ve created, but now I want to retrieve and store data in a...
5
by: Michael Moreno | last post by:
Hello, In a class I have this code: public object Obj; If Obj is a COM object I would like to call in the Dispose() method the following code: ...
12
by: Andrew Poulos | last post by:
With the following code I can't understand why this.num keeps incrementing each time I create a new instance of Foo. For each instance I'm expecting this.num to alert as 1 but keeps incrementing. ...
22
by: Cylix | last post by:
I have a 4row x 1col table, I would like to drop all the content of row three. Since Mac IE5.2 does not suppport deleteRow method, I have also try to set the innerHTML=''; but it does not work. ...
20
by: Justin Rich | last post by:
so im trying to be good and not leave anything hanging open but i guess ive seen a variety of ways to kill objects.. is there like a recommended way? basically im looking for best practices for...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.