Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make a variable public between two aspx webforms? 1

Status
Not open for further replies.

bclt

Programmer
Mar 13, 2005
363
GR
Hi,

What i'm tring to do is:
public a as boolean = false

I need to be able to see the variable from one web form to an other (that's why inputed public). Of course I may not access this variable.

In vb i could try to put this public statement in a module; but in asp.net??

Tnx
 
You could initialize and store it in Session State via Session_Start in Global.asax or if your pages inherited from a base class you could initialize it in that base class or you could declare it in the code-behind of every page. Using Global.asax you'll be able to change the value and persist it for the duration of the session. Using the other methods you're still going to need to persist the value between pages (whether by querystring or hidden form field/ViewState using Server.Transfer. Of course, maybe I'm over-thinking it :)
 
Public Class Global
Inherits System.Web.HttpApplication

Public a As Boolean = False


Still can't access the "a" variable from other web forms. Can u explain it more on how to do this. (Don't use complex expresions; i may not undestand :) )



Tnx
 
try making it shared

public shared a as boolean = true

then you can call it as follows Global.a

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
Do you know how to do this in Asp.Net in visual studio 2005? Did it as in VS2003 but now can't find the variable ...


Tnx
 
Found it!

Must remove "Shared"; just only public:
It is here: Global.ASP.Global_asax.a
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top