I have calling a property from a user control, and it return me an exception - object reference not set to an instance of an object
- Below is part of my code
This is my property Max_Pocket_Value from a user control
Public Property Max_Pocket_Value_() As Integer
Get
Dim MAXIMUM_VALUE As Integer
Try
Dim MAXIMUM_VALUE1 As String = Me.hf_MaxPocketNumber.Value
Integer.TryParse(Me.hf_MaxPocketNumber.Value, MAXIMUM_VALUE)
Dim B As Integer = MAXIMUM_VALUE
If MAXIMUM_VALUE < 0 Then
MAXIMUM_VALUE = -1
End If
Catch ex As Exception
MsgBox("Can't load Web page" & vbCrLf & ex.Message)
End Try
Return MAXIMUM_VALUE
End Get
Set(max_Pocket_Number As Integer)
hf_MaxPocketNumber.Value = max_Pocket_Number.ToString()
End Set
End Property
I set the property value on Page_Init. dataPiece(0).Max_Pocket_ have value of : 9 during debug session
Private Sub Page_Init(sender As Object, e As EventArgs) Handles Me.Init
data_Grabber_()
Me.Max_Pocket_Value_ = dataPiece(0).Max_Pocket_
End Sub`
I call the property on current ascx apge in page_load, and I did tried call the propery in page_init.It result me same exception
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim pocketControl As New GridTableUserControl()
Dim abc As Integer = pocketControl.Max_Pocket_Value_
End Sub
The exception is catch on line below
Public Property Max_Pocket_Value_() As Integer
Get
Dim MAXIMUM_VALUE As Integer
Try
Dim MAXIMUM_VALUE1 As String = Me.hf_MaxPocketNumber.Value
**here -->** Integer.TryParse(Me.hf_MaxPocketNumber.Value, MAXIMUM_VALUE)
Dim B As Integer = MAXIMUM_VALUE
If MAXIMUM_VALUE < 0 Then
MAXIMUM_VALUE = -1
End If
Catch ex As Exception
MsgBox("Can't load Web page" & vbCrLf & ex.Message)
End Try
Return MAXIMUM_VALUE
End Get
Set(max_Pocket_Number As Integer)
hf_MaxPocketNumber.Value = max_Pocket_Number.ToString()
End Set
End Property
Is anyone know what is the issue? Would highly appreciated if I can find some idea here. Thanks!