I am trying to write a web control, but I've run into a major snag.
I cannot find my ViewState data!
Below is a sample of some code I wrote. It worked for a few hours.
I initialise the ViewState with a value when it is first created, and the OnLoad event executes as desired (runs True section). However, when the page reloads, as postback event, the OnLoad event code fails (runs False section). The failure occurs because IsNothing(ViewState("IsSearch")) = True.Code:Protected Overrides Sub OnInit(ByVal e As System.EventArgs) If Not Me.Page.IsPostBack Then 'First creation of control set default value ViewState.Add("IsSearch", True) End If End Sub Protected Overrides Sub OnLoad(ByVal e As System.EventArgs) If ViewState("IsSearch") Then 'Do something Else 'Do something else End If End Sub
Am I doing something wrong here or is Microsoft?![]()
-Drew





