Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / A Question About C# - Visual Express 2005 - "Getters" and "Setters" problem

Author
Message
the Last Programmer
19
Years of Service
User Offline
Joined: 14th Jul 2005
Location: Abilene, TX
Posted: 9th Jan 2006 07:59
Hey, I have no idea why this code isn't working. All I'm trying to do is make a 'getter' and 'setter' method inside C# (using Visual Web Developer 2005 Express Edition).

Here is the Code:



As you can see I created the "Hamster" class. Inside it is the variable "m_helloVar". Then I go on to define some contructor methods and then the 'getter' and 'setter' methods. But when I implement the getter and setter methods in the code using some buttons, the variable remains unchanged.

I've tried several different ways and I can't seem to come up with a solution. I hope someone here can figure it out.

Thanks.


www.fishbrosentertainment.com
the Last Programmer
19
Years of Service
User Offline
Joined: 14th Jul 2005
Location: Abilene, TX
Posted: 9th Jan 2006 09:13
Alright, I think I found the problem. For some reason the object "Joe" is always being recreated everytime I press a button on the page, probably caused by a screen refresh command.

So basically, it sucks.

But I'll just work around it.


www.fishbrosentertainment.com
Toby Quan
21
Years of Service
User Offline
Joined: 16th Oct 2003
Location: U S A
Posted: 9th Jan 2006 14:05
This appears to be a web application. This is expected behavior for a web application. All variables are lost between web posts.

If it was a Windows app, this wouldn't be a problem, because the variables would be alive as long as your form is open. However on Web apps, all variables die after the posting is done.
the Last Programmer
19
Years of Service
User Offline
Joined: 14th Jul 2005
Location: Abilene, TX
Posted: 9th Jan 2006 23:48
Alright, thanks.

I figured as much. I'll just have to set up a database and see if that works.


www.fishbrosentertainment.com
JoelJ
21
Years of Service
User Offline
Joined: 8th Sep 2003
Location: UTAH
Posted: 10th Jan 2006 03:18 Edited at: 10th Jan 2006 03:34
you could also use Application Variables and Server Variables (i think that's what they're called... I'm not sure, it's been a while)

btw, they're called PROPERTIES.

Login to post a reply

Server time is: 2024-11-16 09:41:56
Your offset time is: 2024-11-16 09:41:56