Remember, the web is inherently stateless. That means every page view is
like a brand new occurance of the page. The variables and data is generally
not kept. You have to store the variable somewhere to handle this sort of
thing. Luckily, ASP.Net has the Viewstate. You can store the variable in the
viewstate after you perform some work on it in button one, then retrieve it
in button 2 (and do some work with it again and store it, etc..). Whenever
you access a Viewstate item you'll need to check if it is null first, just
to make sure because if you haven't saved the variable to the viewstate then
it will come back as null and possibly mess up your code.
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
"Raheel Hussain" <ra*******@yahoo.com> wrote in message
news:eH**************@TK2MSFTNGP09.phx.gbl...
hi,
can any body tell me why the variable loses its value,
i m actually declaring a variable which is public, and assigning a
values in Function1 and reading the values in Function2
following is a sample code for wht i m doing.
---------------------------------------
Public Class SupportRequest
Inherits System.Web.UI.Page
Dim Var1 As Integer
..
..
Private function Function1
Var1=1
End Function
Private Function Function2
'Var1 returns 0
Textbox1.text= Var1
End Function
End Class
-------------------------------------------
I call Function1 on click of Button1.
and Function2 at click of Button2.
regards.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!