473,395 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

variable persistence

hey all,

is there a way to persist a client-side variable between postbacks?

thanks,
rodchar
Nov 19 '05 #1
8 1071
Rodchar,

You may store it in a cookie, in a database, in a text file, in viewstate,
or in a session variable. Which is the best would depend on the information
being stored.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:96**********************************@microsof t.com...
hey all,

is there a way to persist a client-side variable between postbacks?

thanks,
rodchar

Nov 19 '05 #2
how do i store a client-side variable in viewstate or session? i'm not sure
of the exact syntax to do this?

"S. Justin Gengo" wrote:
Rodchar,

You may store it in a cookie, in a database, in a text file, in viewstate,
or in a session variable. Which is the best would depend on the information
being stored.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:96**********************************@microsof t.com...
hey all,

is there a way to persist a client-side variable between postbacks?

thanks,
rodchar


Nov 19 '05 #3
rodchar,

To store in viewstate:

Viewstate.Add("MyString", "This is my variable")
Viewstate.Add("MyInt", 13)

To store in session:

Session.Add("MyString", "This is my variable")
Session.Add("MyInt", 13)

Where MyString and MyInt are the keys and then any object may be added as
the value.

To retrieve:

Dim MyString As String = Viewstate.Item("MyString").toString
Dim MyInt As Int32 = CType(Viewstate.Item("MyInt"), Int32)

Dim MyString As String = Session.Item("MyString").toString
Dim MyInt As Int32 = CType(Session.Item("MyInt"), Int32)
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:4E**********************************@microsof t.com...
how do i store a client-side variable in viewstate or session? i'm not
sure
of the exact syntax to do this?

"S. Justin Gengo" wrote:
Rodchar,

You may store it in a cookie, in a database, in a text file, in
viewstate,
or in a session variable. Which is the best would depend on the
information
being stored.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:96**********************************@microsof t.com...
> hey all,
>
> is there a way to persist a client-side variable between postbacks?
>
> thanks,
> rodchar


Nov 19 '05 #4
You don't. Use either a cookie or a hidden textbox.

Eliyahu

"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:4E**********************************@microsof t.com...
how do i store a client-side variable in viewstate or session? i'm not sure of the exact syntax to do this?

"S. Justin Gengo" wrote:
Rodchar,

You may store it in a cookie, in a database, in a text file, in viewstate, or in a session variable. Which is the best would depend on the information being stored.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:96**********************************@microsof t.com...
hey all,

is there a way to persist a client-side variable between postbacks?

thanks,
rodchar


Nov 19 '05 #5
I understood the OP asked how to do it from client side.

Eliyahu

"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate.com> wrote in
message news:u2*************@TK2MSFTNGP15.phx.gbl...
rodchar,

To store in viewstate:

Viewstate.Add("MyString", "This is my variable")
Viewstate.Add("MyInt", 13)

To store in session:

Session.Add("MyString", "This is my variable")
Session.Add("MyInt", 13)

Where MyString and MyInt are the keys and then any object may be added as
the value.

To retrieve:

Dim MyString As String = Viewstate.Item("MyString").toString
Dim MyInt As Int32 = CType(Viewstate.Item("MyInt"), Int32)

Dim MyString As String = Session.Item("MyString").toString
Dim MyInt As Int32 = CType(Session.Item("MyInt"), Int32)
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:4E**********************************@microsof t.com...
how do i store a client-side variable in viewstate or session? i'm not
sure
of the exact syntax to do this?

"S. Justin Gengo" wrote:
Rodchar,

You may store it in a cookie, in a database, in a text file, in
viewstate,
or in a session variable. Which is the best would depend on the
information
being stored.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:96**********************************@microsof t.com...
> hey all,
>
> is there a way to persist a client-side variable between postbacks?
>
> thanks,
> rodchar


Nov 19 '05 #6
Yes,

But if he posts back... It's no longer just client side is it? So what's the
point of limiting it to client side then? I'm just trying to understand why
not use a "server side solution". Of course if the variable needs to be
accessed again client-side then you're right, a hidden field or a cookie is
about the only choice. (Unless you get into Ajax).

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:Og**************@TK2MSFTNGP09.phx.gbl...
I understood the OP asked how to do it from client side.

Eliyahu

"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate.com> wrote in
message news:u2*************@TK2MSFTNGP15.phx.gbl...
rodchar,

To store in viewstate:

Viewstate.Add("MyString", "This is my variable")
Viewstate.Add("MyInt", 13)

To store in session:

Session.Add("MyString", "This is my variable")
Session.Add("MyInt", 13)

Where MyString and MyInt are the keys and then any object may be added as
the value.

To retrieve:

Dim MyString As String = Viewstate.Item("MyString").toString
Dim MyInt As Int32 = CType(Viewstate.Item("MyInt"), Int32)

Dim MyString As String = Session.Item("MyString").toString
Dim MyInt As Int32 = CType(Session.Item("MyInt"), Int32)
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:4E**********************************@microsof t.com...
> how do i store a client-side variable in viewstate or session? i'm not
> sure
> of the exact syntax to do this?
>
> "S. Justin Gengo" wrote:
>
>> Rodchar,
>>
>> You may store it in a cookie, in a database, in a text file, in
>> viewstate,
>> or in a session variable. Which is the best would depend on the
>> information
>> being stored.
>>
>> --
>> Sincerely,
>>
>> S. Justin Gengo, MCP
>> Web Developer / Programmer
>>
>> www.aboutfortunate.com
>>
>> "Out of chaos comes order."
>> Nietzsche
>> "rodchar" <ro*****@discussions.microsoft.com> wrote in message
>> news:96**********************************@microsof t.com...
>> > hey all,
>> >
>> > is there a way to persist a client-side variable between postbacks?
>> >
>> > thanks,
>> > rodchar
>>
>>
>>



Nov 19 '05 #7
Using an hidden field you can transmit back and forth the value...

Where do you need this exactly ? (you could use a cookie if you need this
only client side and find this acceptable).
--
Patrice

"rodchar" <ro*****@discussions.microsoft.com> a écrit dans le message de
news:96**********************************@microsof t.com...
hey all,

is there a way to persist a client-side variable between postbacks?

thanks,
rodchar

Nov 19 '05 #8
to store my javascript variable in viewstate, i had to use an html hidden
textbox which i converted to run at server and that seem to have work well,
thanks.

rodchar

"Patrice" wrote:
Using an hidden field you can transmit back and forth the value...

Where do you need this exactly ? (you could use a cookie if you need this
only client side and find this acceptable).
--
Patrice

"rodchar" <ro*****@discussions.microsoft.com> a écrit dans le message de
news:96**********************************@microsof t.com...
hey all,

is there a way to persist a client-side variable between postbacks?

thanks,
rodchar


Nov 19 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Simon Harvey | last post by:
Hi everyone, Can anyone tell me if I declare a global variable in my pages code behind, is it persisted if the page does a post back, or do I need to add the object to the session object in...
5
by: Simon Harvey | last post by:
Hi everyone, Can anyone tell me if I declare a global variable in my pages code behind, is it persisted if the page does a post back, or do I need to add the object to the session object in...
5
by: Simon Harvey | last post by:
Hi everyone, Can anyone tell me if I declare a global variable in my pages code behind, is it persisted if the page does a post back, or do I need to add the object to the session object in...
2
by: dkode | last post by:
Hello, I am laying out the architecture for a very large website that will scale to a very large degree. I have a couple of questions before I attempt to go and implement a Broker/Persistence...
0
myusernotyours
by: myusernotyours | last post by:
Hi all, Am trying to create a Java Desktop App that uses Java Persistence in Netbeans. The database is MS Access but I tried with Mysql and got the same error. When I run the app( Create the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.