我需要帮助使此代码更好地工作。目前,当它重新加载时,我会丢失第三个值,即计算值。我希望我的页面在不丢失页面上每个属性和每个用户控件实例的值的情况下重新加载。
提前致谢
Private _Length As Double = 0.0
Public Property Length() As Double
Get
If (Me.ViewState("calcLength") IsNot Nothing) Then
Return CType(ViewState("calcLength"), Double)
End If
Return _Length
End Get
Set(ByVal value As Double)
ViewState("calcLength") = value
txtLength.Text = value.ToString()
_Length = value
End Set
End Property
Private _Width As Double = 0.0
Public Property Width() As Double
Get
If (Me.ViewState("calcwidth") IsNot Nothing) Then
Return CType(Me.ViewState("calcwidth"), Double)
End If
Return _Width
End Get
Set(ByVal value As Double)
Me.ViewState("calcwidth") = value
Me.txtwidth.Text = value.ToString()
_Width = value
End Set
End Property
Private _calculatedboardfeet As Double = 0.0
Public Property CalculateBoardFeet() As Double
Get
If (Me.ViewState("calculateboardfeet") IsNot Nothing) Then
_calculatedboardfeet = CType(ViewState("calculateboardfeet"), Double)
End If
Return _calculatedboardfeet
End Get
Set(ByVal value As Double)
Me.ViewState("calculateboardfeet") = value
Me.lblCalculatedValue.Text = String.Format("{0:f2}", value)
_calculatedboardfeet = value
End Set
End Property