I need help making this code work better. Currently, what happens is when it reloads, I loose the third value which is a calculated value . I would like for my page to reload without loosing the values for each property and each instance of the user control on the page.
Thanks in advance
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