Web form retains values over diferent stations

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an ASP.NET web form that is retaining values over different stations
on the network, how can I stop this behavior ?. I didn’t do anything special
to cause it.

Thanks
C.Fleury
 
What values ? (form fields value ?). From where are coming those values in
your application ?

Most often when you have the same values on several wstations this is
because you used shared (or a VB.NET module) (or static in C#) members... Is
this the case ?

Patrice
 
Patrice,

All objects are unbound textboxes in which the user enters data manually…I
do have this code in my “page_load†event, which retains the form values in
between postbacks, in this case “sys†is a public structure:

If Not IsPostBack Then
txb1.Text = IIf(Empty(sys._1), "0", sys._1)
txb2.Text = IIf(Empty(sys._2), "0", sys._2)
txb5.Text = IIf(Empty(sys._5), "0", sys._5)
txb10.Text = IIf(Empty(sys._10), "0", sys._10)
txb20.Text = IIf(Empty(sys._20), "0", sys._20)
txb50.Text = IIf(Empty(sys._50), "0", sys._50)
txb100.Text = IIf(Empty(sys._100), "0", sys._100)
txbCoins.Text = IIf(Empty(sys._Coins), "0", sys._Coins)
End If

Thanks Patrice
C.Fleury
 
How is defined this structure ? In a module ?

Just to make it clear (english is not my native language) do you mean that
you see the same values accross several wstations or do you mean values on a
particular workstations are kept intact when you postback ? My understanding
is that you see the first behavior (values seemed to be "shared" accross
several workstations).

Patrice

--
 
The first behavior, Patrice, the same values are seem across all wstations...
Thanks
C.Fleury
 
In a module as public like:

Public Structure _sys
Public _1 As String
Public _2 As String
Public _5 As String
Public _10 As String
Public _20 As String
Public _50 As String
Public _100 As String
Public _Coins As String
End Structure

Public sys As _sys

and then I use that structure in the aspx in question the following way:

If Not IsPostBack Then
' values were assigned to sys in an onclick event handler....
txb1.Text = IIf(Empty(sys._1), "0", sys._1)
txb2.Text = IIf(Empty(sys._2), "0", sys._2)
txb5.Text = IIf(Empty(sys._5), "0", sys._5)
txb10.Text = IIf(Empty(sys._10), "0", sys._10)
txb20.Text = IIf(Empty(sys._20), "0", sys._20)
txb50.Text = IIf(Empty(sys._50), "0", sys._50)
txb100.Text = IIf(Empty(sys._100), "0", sys._100)
txbCoins.Text = IIf(Empty(sys._Coins), "0", sys._Coins)
End If

Thanks again Patrice
C.Fleury
 
The problem is that this structure is defined in a module. In VB.NET a
module is implemented as a class with shared members.

The "Shared" keyword allows to define members that belong to a class (or if
you prefer that are the same for all objects). In ASP.NET, even though you
have multiple users, this is a single application. As a result all users are
sharing the same structure.

Patrice

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top