473,412 Members | 2,051 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,412 software developers and data experts.

Anyone have a clue why this happens??

Dan
Hi guys

I have an aspx page that accepts a posted to field, the id number of a
product.

On the page it then loads the details and allows editing of the product with
a save button. The save button fires off sql to save the changes using that
id number posted.

My problem i had was that between postbacks the id number was not retained.
So when i clicked save and a round trip post back occurred the id was lost.
So i made my variable that accepted the product id static. Problem solved.

However i have now found that if i load the page and edit a product and my
collegue loads the page on his comp to edit a different product that when he
clicks save it attempts to update the details on his page to the product id
of the one i am looking at.

So somehow my posted data has stayed and when he has gone in to his it has
kept my product id? Anyone have a clue how that can happen?

Here is a snippet of my page load function (c# code)

if(!Page.IsPostBack)

{

vestry.dbCommands dbObj = new vestry.dbCommands();

System.Collections.Specialized.NameValueCollection postData = new
System.Collections.Specialized.NameValueCollection ();
if(Request.RequestType == "GET")

postData = Request.QueryString;

else

postData = Request.Form;

productId = int.Parse(postData.Get("productId"));

...............}

As you can see from above i take the posted data and set it to my static int
productId variable. I am presuming it is because i set it static that this
occurs. But how, without setting the product id static, can i keep it
retained from page to page without it being placed inside a text box or
similar?

Thanks
--
Dan
Jan 31 '06 #1
3 1090
Well, you never really want to make something state in a web environment
because all users will end up sharing the same copy of the variable.

Create a hidden field and set the value of that field to you ID when the
page renders. Then grab that ID when the page is submitted.

"Dan" <dv*******@aol.com> wrote in message
news:u7**************@TK2MSFTNGP11.phx.gbl...
Hi guys

I have an aspx page that accepts a posted to field, the id number of a
product.

On the page it then loads the details and allows editing of the product
with a save button. The save button fires off sql to save the changes
using that id number posted.

My problem i had was that between postbacks the id number was not
retained. So when i clicked save and a round trip post back occurred the
id was lost. So i made my variable that accepted the product id static.
Problem solved.

However i have now found that if i load the page and edit a product and my
collegue loads the page on his comp to edit a different product that when
he clicks save it attempts to update the details on his page to the
product id of the one i am looking at.

So somehow my posted data has stayed and when he has gone in to his it has
kept my product id? Anyone have a clue how that can happen?

Here is a snippet of my page load function (c# code)

if(!Page.IsPostBack)

{

vestry.dbCommands dbObj = new vestry.dbCommands();

System.Collections.Specialized.NameValueCollection postData = new
System.Collections.Specialized.NameValueCollection ();
if(Request.RequestType == "GET")

postData = Request.QueryString;

else

postData = Request.Form;

productId = int.Parse(postData.Get("productId"));

..............}

As you can see from above i take the posted data and set it to my static
int productId variable. I am presuming it is because i set it static that
this occurs. But how, without setting the product id static, can i keep it
retained from page to page without it being placed inside a text box or
similar?

Thanks
--
Dan

Jan 31 '06 #2
Dan wrote:
Hi guys

I have an aspx page that accepts a posted to field, the id number of a
product.

On the page it then loads the details and allows editing of the product with
a save button. The save button fires off sql to save the changes using that
id number posted.

My problem i had was that between postbacks the id number was not retained.
So when i clicked save and a round trip post back occurred the id was lost.
So i made my variable that accepted the product id static. Problem solved.

However i have now found that if i load the page and edit a product and my
collegue loads the page on his comp to edit a different product that when he
clicks save it attempts to update the details on his page to the product id
of the one i am looking at.

So somehow my posted data has stayed and when he has gone in to his it has
kept my product id? Anyone have a clue how that can happen?

Here is a snippet of my page load function (c# code)

if(!Page.IsPostBack)

{

vestry.dbCommands dbObj = new vestry.dbCommands();

System.Collections.Specialized.NameValueCollection postData = new
System.Collections.Specialized.NameValueCollection ();
if(Request.RequestType == "GET")

postData = Request.QueryString;

else

postData = Request.Form;

productId = int.Parse(postData.Get("productId"));

..............}

As you can see from above i take the posted data and set it to my static int
productId variable. I am presuming it is because i set it static that this
occurs. But how, without setting the product id static, can i keep it
retained from page to page without it being placed inside a text box or
similar?

Thanks


I suggest much reading on how ASP.NET really works. Google for ASP.NET
Page Lifecycle.

While not a static variable, you can maintain state information in the
Session or Application dictionaries.

--
Jay R. Wren
Jan 31 '06 #3
Thanks guys

Thanks Jay but thats not what i am after. Spot on tho Pete, i presumed with
the code behind on the aspx pages that for each user a new instance of the
code behind class would be created, therefore keeping the static var to just
that user. From what you have said this isn't the case at all, i was hoping
that aspx had destroyed the need for the old style 'hidden fields' posting.

D

"Jay R. Wren" <jr****@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Dan wrote:
Hi guys

I have an aspx page that accepts a posted to field, the id number of a
product.

On the page it then loads the details and allows editing of the product
with
a save button. The save button fires off sql to save the changes using
that
id number posted.

My problem i had was that between postbacks the id number was not
retained.
So when i clicked save and a round trip post back occurred the id was
lost.
So i made my variable that accepted the product id static. Problem
solved.

However i have now found that if i load the page and edit a product and
my
collegue loads the page on his comp to edit a different product that when
he
clicks save it attempts to update the details on his page to the product
id
of the one i am looking at.

So somehow my posted data has stayed and when he has gone in to his it
has
kept my product id? Anyone have a clue how that can happen?

Here is a snippet of my page load function (c# code)

if(!Page.IsPostBack)

{

vestry.dbCommands dbObj = new vestry.dbCommands();

System.Collections.Specialized.NameValueCollection postData = new
System.Collections.Specialized.NameValueCollection ();
if(Request.RequestType == "GET")

postData = Request.QueryString;

else

postData = Request.Form;

productId = int.Parse(postData.Get("productId"));

..............}

As you can see from above i take the posted data and set it to my static
int
productId variable. I am presuming it is because i set it static that
this
occurs. But how, without setting the product id static, can i keep it
retained from page to page without it being placed inside a text box or
similar?

Thanks


I suggest much reading on how ASP.NET really works. Google for ASP.NET
Page Lifecycle.

While not a static variable, you can maintain state information in the
Session or Application dictionaries.

--
Jay R. Wren

Jan 31 '06 #4

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

Similar topics

0
by: Geir Arne Evjen | last post by:
I'm having a strange problem which I hope some python experts out there could help me with. I'm implementing a COM server where I do a lot of xml-rpc calls to a zope server. The communication is...
162
by: Isaac Grover | last post by:
Hi everyone, Just out of curiosity I recently pointed one of my hand-typed pages at the W3 Validator, and my hand-typed code was just ripped to shreds. Then I pointed some major sites...
4
by: Iver Erling Årva | last post by:
I have an application that uses a window.open() to open it's own main window where all my programs takes place. I use a timeout so if nothing goes on for 15 minutes the document below is called. To...
1
by: Anna K. | last post by:
Hi Experts, I'm new to JavaScript and web-based apps development, so I'll tell you right off that I don't really know my way around it as of yet. I'm trying to create a code library set with...
2
by: Fred | last post by:
Hi. Sorry, but I don't know where else to ask. I wrote a access shipping database and we currently use the web interface for DHL to print shipping labels. That means we have to manualy transpose...
1
by: Lauren Wilson | last post by:
I'm having trouble with the Access VBA help on my installation of A2K with Dev tools. Every time I try to retrieve help for items listed in the Object Browser (and SOME other items as well),...
15
by: _BNC | last post by:
Recently I had posted a query about intermittent problems with a C++/Interop scheme (unmanaged C DLL wrapped in unmanaged C++, wrapped in managed C++, all accessed by C#). The system works fine...
2
by: Max Metral | last post by:
I get sporadic viewstate errors from Macintosh browsers. I get mailed the form values when this happens, and it appears that the problem is the encoding of the POST value from the browser. ...
2
by: Lauren Wilson | last post by:
Hi Folks, We have a user who is suddenly getting the following error message when they start our very mature application. Other users of the same version are NOT getting this error: "Error...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
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,...
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
Oralloy
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,...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...

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.