[英]what variable i can use instead of shared?
I have the following variable which creates problem when i use multiples instance of the same web form. 我有以下变量,当我使用同一Web表单的多个实例时会产生问题。 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
只需删除“ Shared
,一切都会正常。
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. 对于每个共享变量,将其转换为WebForm上的属性。 Then store the values in the ViewState
然后将值存储在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. 请注意,我是在运行时而不是在VS中进行编码的,因此您可能需要对其进行调整。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.