Environment: Asp.net 4.5, Webforms
I'm creating a composite control. I've exposed multiple public properties, but running into a slight problem.
Let's say I have two properties:
Public Property Path() As String
Get
Return ViewState("Path")
End Get
Set(ByVal Value As String)
If UseAbsolute = True Then
' do something
Else
' it always lands heere...
End If
End If
ViewState("Path") = Value
End Set
End Property
Private _Path As String = String.Empty
Public Property UseAbsolute() As Boolean
....
End Property
Private _UseAbsolute As Boolean = False
My controls are being assigned values on PreRender. The problem is, when I call "Path" it's getting the default/private value for UseAbsolute. So even if I set the property to True in the control/html, it grabs the false first.
I can work around this many ways, but I feel I'm missing a proper method or understanding.
UPDATE
I forgot to mention. I am:
EnsureChildControls()
in the PreRender...
I also tried adding this to the properties themselves.
Shouldn't Your code be like this instead of how you have it?