views:

52

answers:

2

I have the following variable which creates problem when i use multiples instance of the same web form. Could you please let me know how i could what variables other than shared i can use to achieve this purpose?

Public strRoleType As String = String.Empty
Protected Shared isAreaSelected As Integer = 0
Protected Shared isStoreSelected As Integer = 0
Protected Shared isHeadOfficeSelected As Integer = 0
Protected Shared isRegionSelected As Integer = 0
+1  A: 

Just remove Shared and everything should be fine.

klausbyskov
nope... when i removed shared .the the form is not working as expeected
Please refer the link .. this is the exact problem i am facing : http://stackoverflow.com/questions/2514534/guessess-of-my-session-value-conflicts
I read your post and I think you are very, very confused about the way that ASP.NET works when multiple people are looking at the site at the same time. I don't understand why you are using a combination of page variables and session variables, and since your application consists of only one .aspx, page variables are plenty appropriate (otherwise use session variables). That is, use one or the other, and you don't need 'shared' in your application.
rlb.usa
but i remove the shared keywords from the variable declaration. the web form is not at all bypassing the 3rd page when i select any value in the first page..so whats wrong there?
@SmartestVEGA, I think you are missing the fact that the web is stateless.
Mattias Jakobsson
A: 

This is a lot of work but it creates form level storage

For each of your shared variables convert it to a property on the WebForm. Then store the values in the ViewState

'default to 0 if blank, else convert to int
Public Property IsAreaSelected() As Integer
    Get
        Return If(ViewState("IsAreaSelected") Is Nothing, 0, Cint(ViewState("IsAreaSelected")))
    End Get
    Set(ByVal value As Integer)
        ViewState("IsAreaSelected") = value
    End Set
End Property

This way the values stay with the page.

Please note I coded this up on the fly and not in VS so you may have to tweak it.

Cheddar