Variable problems in aspnet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi...

This my first webapplication using aspnet, so I just notice this problem yesterday.
I create a Private Variable in the webapplication class, with no start values, in a certain function it changes the value of the variable, but when I try to read the variable again it is clear, or its value is just a 0 (for integer ones).

Here is some small code jsut to have an idea

Private test as String
Private Function ChangeValue()
test = "Now it has some value"
messagebox.show(test) 'Returns a clear string
End Function

I think that is something wrong with my IIS.

Any help will be very useful.

Thanks in advanced.
 
For one thing, the MessageBox class isn't designed to be used in web
applications. You need to use client-side JavaScript for that.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

ltt19 said:
Hi...

This my first webapplication using aspnet, so I just notice this problem yesterday.
I create a Private Variable in the webapplication class, with no start
values, in a certain function it changes the value of the variable, but when
I try to read the variable again it is clear, or its value is just a 0 (for
integer ones).
 
Ohh... sorry... I wrote it wrong, but just in this example... I already know that its not supported.. but in this example I wrote this, sorry, so anyway, even if it is not a messagebox, for example, a caption of some object, is does not work anyway, I also treid with the debbugerm using the STOP keyword, when I ask the value of this variable in the window, it returns Clear or 0, as I said before.

Sorry.. if you can help me
 
If you try to read the variable after a button click or something like that,
it is going to reinitialize the variable when the page loads. You can store
a variable using session("variablename") = "Value" if you need to keep the
value of the variable after the page reloads. Also I have tried storing
variables in a texbox with visable set to "false" but this is a little
tricky. If it is all in the same sub as your example was, I have no idea
because it should work OK.

ltt19 said:
Hi...

This my first webapplication using aspnet, so I just notice this problem yesterday.
I create a Private Variable in the webapplication class, with no start
values, in a certain function it changes the value of the variable, but when
I try to read the variable again it is clear, or its value is just a 0 (for
integer ones).
 
I would tend to think the same thing. It sounds like the variable is not
surviving a PostBack to me as well. It is better to store the variable in
ViewState in this case, I would think. Consumes less server-side memory. As
long as the variable is only used in this page, and is not hundreds of KB in
size, ViewState would be the way to go.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
Back
Top