Hi,
I am designing an ASP.NET application in which particular pages require global variables that need to be persisted during postbacks. What is the best practice to do this?
Is it to use the viewstate object or is declaring the variables as static sufficient (I am currently using this method)?
Thank you,
Mark Anthony Spiteri 13 1884
On Sat, 26 Jun 2004 08:08:01 -0700, "Mark Anthony Spiteri"
<mark@[remove]mspiteri.com> wrote: Hi,
I am designing an ASP.NET application in which particular pages require global variables that need to be persisted during postbacks. What is the best practice to do this?
Is it to use the viewstate object or is declaring the variables as static sufficient (I am currently using this method)?
You'll need to use the ViewState object, or perhaps the Session
object. A static variable isn't enough - in a web environment the
application is restarted for every request, so your static variables
are being reinitialised.
Gareth
Thank you for your reply.
"Gareth Jones" wrote: On Sat, 26 Jun 2004 08:08:01 -0700, "Mark Anthony Spiteri" <mark@[remove]mspiteri.com> wrote:
Hi,
I am designing an ASP.NET application in which particular pages require global variables that need to be persisted during postbacks. What is the best practice to do this?
Is it to use the viewstate object or is declaring the variables as static sufficient (I am currently using this method)?
You'll need to use the ViewState object, or perhaps the Session object. A static variable isn't enough - in a web environment the application is restarted for every request, so your static variables are being reinitialised.
Gareth
Thank you for your reply
"Gareth Jones" wrote: On Sat, 26 Jun 2004 08:08:01 -0700, "Mark Anthony Spiteri" <mark@[remove]mspiteri.com> wrote:
Hi,
I am designing an ASP.NET application in which particular pages require global variables that need to be persisted during postbacks. What is the best practice to do this?
Is it to use the viewstate object or is declaring the variables as static sufficient (I am currently using this method)?
You'll need to use the ViewState object, or perhaps the Session object. A static variable isn't enough - in a web environment the application is restarted for every request, so your static variables are being reinitialised.
Gareth
Thank you for your reply.
"Gareth Jones" wrote: On Sat, 26 Jun 2004 08:08:01 -0700, "Mark Anthony Spiteri" <mark@[remove]mspiteri.com> wrote:
Hi,
I am designing an ASP.NET application in which particular pages require global variables that need to be persisted during postbacks. What is the best practice to do this?
Is it to use the viewstate object or is declaring the variables as static sufficient (I am currently using this method)?
You'll need to use the ViewState object, or perhaps the Session object. A static variable isn't enough - in a web environment the application is restarted for every request, so your static variables are being reinitialised.
Gareth
Thank you for your reply
"Gareth Jones" wrote: On Sat, 26 Jun 2004 08:08:01 -0700, "Mark Anthony Spiteri" <mark@[remove]mspiteri.com> wrote:
Hi,
I am designing an ASP.NET application in which particular pages require global variables that need to be persisted during postbacks. What is the best practice to do this?
Is it to use the viewstate object or is declaring the variables as static sufficient (I am currently using this method)?
You'll need to use the ViewState object, or perhaps the Session object. A static variable isn't enough - in a web environment the application is restarted for every request, so your static variables are being reinitialised.
Gareth
Are the values of the page global variables supposed to be the same
for all of the users who visit the page?
--
Scott http://www.OdeToCode.com
On Sat, 26 Jun 2004 08:08:01 -0700, "Mark Anthony Spiteri"
<mark@[remove]mspiteri.com> wrote: Hi,
I am designing an ASP.NET application in which particular pages require global variables that need to be persisted during postbacks. What is the best practice to do this?
Is it to use the viewstate object or is declaring the variables as static sufficient (I am currently using this method)? Thank you,
Mark Anthony Spiteri
No,
each user will have different variable values. Thus making use of the Application Object is futile.
"Scott Allen" wrote: Are the values of the page global variables supposed to be the same for all of the users who visit the page?
-- Scott http://www.OdeToCode.com
On Sat, 26 Jun 2004 08:08:01 -0700, "Mark Anthony Spiteri" <mark@[remove]mspiteri.com> wrote:
Hi,
I am designing an ASP.NET application in which particular pages require global variables that need to be persisted during postbacks. What is the best practice to do this?
Is it to use the viewstate object or is declaring the variables as static sufficient (I am currently using this method)? Thank you,
Mark Anthony Spiteri
Yes, this also rules out using static variables. As suggested, Session
state and Viewstate are both options.
--s
On Sun, 27 Jun 2004 09:05:01 -0700, "Mark Anthony Spiteri"
<mark@[remove]mspiteri.com> wrote: No,
each user will have different variable values. Thus making use of the Application Object is futile.
"Scott Allen" wrote:
Are the values of the page global variables supposed to be the same for all of the users who visit the page?
-- Scott http://www.OdeToCode.com
On Sat, 26 Jun 2004 08:08:01 -0700, "Mark Anthony Spiteri" <mark@[remove]mspiteri.com> wrote:
>Hi, > >I am designing an ASP.NET application in which particular pages require global variables that need to be persisted during postbacks. What is the best practice to do this? > >Is it to use the viewstate object or is declaring the variables as static sufficient (I am currently using this method)? > > > >Thank you, > >Mark Anthony Spiteri
--
Scott http://www.OdeToCode.com
Are the values of the page global variables supposed to be the same
for all of the users who visit the page?
--
Scott http://www.OdeToCode.com
On Sat, 26 Jun 2004 08:08:01 -0700, "Mark Anthony Spiteri"
<mark@[remove]mspiteri.com> wrote: Hi,
I am designing an ASP.NET application in which particular pages require global variables that need to be persisted during postbacks. What is the best practice to do this?
Is it to use the viewstate object or is declaring the variables as static sufficient (I am currently using this method)? Thank you,
Mark Anthony Spiteri This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Paolo Losi |
last post by:
Hi all,
I'm pretty new to the python language so please excuse me
if this is FAQ... I'm very glad to be part of the list! :-)
I'm looking into a way to implement a generic workflow framework with python.
The basic idea is to use python scripts as the way to specify workflow
behavior. The framework should not only use scripts as a specification language
but is going to leverage on python interpreter for the execution of the
scripts.
One...
|
by: ketulp_baroda |
last post by:
Hi
Global variables are not truly global in Python ; they are only global
within a module namespace. I want a variable such that if i change its
value in any module then it should be reflected in other modules too.
What I mean is I wanta varibale say i whose initial value is 1.
If I change value of i in foo.py to say 5 and now I print value of i
in bar.py ,it should print 5.How to do this??
--
|
by: Brad |
last post by:
Hi everyone,
I've been using ASP on a few different projects over the past year, either
using Javascript or VBScript. During that time, I've made use of session
variables, but even then, I've tried to keep those variables to a minimum
(which is not always easy).
I've also read on many ASP resource sites (such as fuzzysoftware.com, etc)
that the use of session variables can be a no-no, while others say that it's
perfectly valid to use...
|
by: Mr. Ed |
last post by:
This should be easy, but I can't immediately see what the answer is...
I have some code which needs to be re-entrant. It also needs to create
a unique identifier. The obvious way to create a unique ID is to
maintain a static counter, and to increment it each time it's needed.
Any ideas on how to do this in a re-entrant way?
I don't call this code (it's Yacc output), so I can't suppy anything
on the stack.
|
by: Diffident |
last post by:
Hello All,
I have written a webform which is by default derived from "Page" class. I
have coded another utility class with few methods and an object of this class
is instantiated from the webfom class.
Methods inside the utility class set few global variables which act as
mediums of persistence to hold data. Now my question is all works fine during
my initial request and all the global variables are set correctly, but during
later...
| |
by: Steve Mauldin |
last post by:
I have a public variable that is declared in a public module. This Variable
is stored into a Session variable and used to pass data from page to page.
I am seeing on my local development box that once the variable is created
and loaded with data and stored into the session variable that on the next
aspx page, before the first line of the page load is executed, the public
variables data persists. I have not done an assignment from the...
|
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 Layer.
1. With a broker layer, does this layer sit at the same level as the
Business Layer? So to speak, the presentation layer has knowledge of
|
by: Richard Carpenter |
last post by:
I have a four-page tabcontrol with a gridview on each page. I have the
primary key column of each gridview set to hidden (visible = false),
but it still shows up on all but the first page. Anyone else see this
behavior? How might I correct it?
|
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 entity manager), I keep getting the following...
Exception in thread "AWT-EventQueue-0" javax.persistence.PersistenceException: No Persistence provider for EntityManager named ReceiptingPU: The following providers:...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |