Re: Global variable

From: ruca (ruuca_at_iol.pt)
Date: 04/28/04


Date: Wed, 28 Apr 2004 12:21:53 +0100

But why this works with links, and not with buttons? This is what I can't
understand.

-- 
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
"Patrice" <nobody@nowhere.com> escreveu na mensagem
news:OX0cJIRLEHA.1144@TK2MSFTNGP12.phx.gbl...
> ASP.NET simulates the usual statefull event driven programming model but
> it's worth to note that the server side "model" and what you have client
> side is not the same "thing". The server side "model" is used to create
the
> client side code (mostly HTML+JavaScript snippets) that will reproduce
what
> you modelled server side. Client-side you'll have also some info (the
> viewstate) that allows to recreate automatically the server side model
from
> scratch during the next server round trip.
>
> In your case, you initialize a variable client side code, then you have a
> postback. The server side "model" is recreated to regenerate client side
> code (possibly updated depending on what you do on postback). When the new
> code is returned to the navigator the client side variable is initialized
> again.
>
> This variable should be persisted beetween calls (for example using an
> hidden field). You should find more details on the general architecture in
> the documentation.
>
> Patrice
>
>
> "ruca" <ruuca@iol.pt> a écrit dans le message de
> news:%239L%23ZrQLEHA.2396@TK2MSFTNGP12.phx.gbl...
> > Hi Patrice,
> >
> > > Dont' you have a local variable that uses the same name ?
> > No.
> >
> > > Do you have a postaback between these two calls ? (that would
> reinitialize
> > > of course the variable value though it shouldn't be false).
> > I think that what happens is that when I click on button the page load
> > again, right?
> > But If I have a link (with href=...) instead of a button (click event)
the
> > thing works fine.
> >
> > But in Load event I have:
> >
> > if not Page.IsPostBack() then
> >     ...
> > end if
> >
> >
> > -- 
> > 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
> >
> >
> > "Patrice" <nobody@nowhere.com> escreveu na mensagem
> > news:uIiK7YQLEHA.1484@tk2msftngp13.phx.gbl...
> > > It should work. Try :
> > >
> > > var v;
> > > function a(){v=true}
> > > function b(){alert(b)}
> > > a();
> > > b(); // Should display true
> > >
> > > Dont' you have a local variable that uses the same name ?
> > > Do you have a postaback between these two calls ? (that would
> reinitialize
> > > of course the variable value though it shouldn't be false).
> > >
> > > Patrice
> > >
> > >
> > > "ruca" <ruuca@iol.pt> a écrit dans le message de
> > > news:%23e05hDQLEHA.1192@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
> > > >
> > > >
> > >
> > >
> >
> >
>
>

Loading