There's a way around this, thought its not direct, depending on the context
of your "Global" definition.
You can access Cookie values through JavaScript. If you manage a variable
by always referring to a value inside of the client's cookie, then that
should work. (Global within a User's context, as opposed to a session
context)
You could, instead of using a js variable (var x;) always refer to a value
that is inside of a hidden field (make sure that the hidden field is set to
runat="server"). This would be "global" within a given page context.
You could subclass your page class. Create a Class, deriving from page,
that has a hidden field. When the page posts back, you perform some sort of
synch operation with that hidden field and an application/Session variable
and expose that value as a property of the page. That way all of the pages
that derive from this subclass would automatically have access to that
variable (effectively creates a "Global" Session/Applicatoin) level value
that script can access). Side Note...if you subclass your Page class,
you'll want to place the subclass inside of a seperate assembly and set a
reference to it in the Visual Studio IDE, otherwise the designer gets a
little funky.
If there's any way around doing this, I'd recommend it. Take a step back
and see if there's something you can do to your architecture to make this
unnecessary. However, these approaches should work if you have to take the
approach you're looking at.
"ruca" <ru***@iol.pt> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
How can I declare a global variable in my .js file, that I can preserve
her value each time I need to call any function of .JS file in my ASP.NET
application?
Example:
var aux=null;
function myFunction1()
{
...
}
function myFunction2()
{
...
}
Now when I call myFunction1(), aux = true, and when I call myFunction2(),
aux = false. The problem is that I need to preserve the previous value to
test it in both functions. How?
Help me please.
Both functions are called in click event of 2 button's.
--
Programming ASP.NET with VB.NET
Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca