Object Reference Error on Custom Control Postback
I have a main page that contains a repeater control. In the first column, each entry has a radio button.
A user clicks the radio button of the client they want and then selects from a dropdownlist outside of the repeater depending on the action they want and then clicks a button.
This should show a specific custom control based on the selection in the dropdownlist and pass an instance of the client to the specific custom control.
Up to this point, it seems to work fine.
Each custom control is a form, such as log phonecall, add task etc. However, when you complete details of, for example, a phonecall and click Add, it loses the instance of the client that was passed to it.
Content Page:-
Code:
Select Case ddl_client_option.selectedvalue
Case "phone"
client_phone.visible = true
client_phone.SiteDetails = Master.SiteDetails
client_phone.UserDetails = Master.UserDetails
client_phone.ClientDetails = ClientDetails
client_phone.update_details()
.
.
client_phone.ascx.vb
Code:
Private _ClientDetails As ClientBOL
Public Property ClientDetails() As ClientBOL
Get
Return _ClientDetails
End Get
Set(ByVal value As ClientBOL)
_ClientDetails = value
End Set
End Property
I have the same for SiteDetails & UserDetails
Private note as New FileNoteBOL
Public Sub update_details()
If Not IsNothing(ClientDetails) then
txt_homephone.text = ClientDetails.homephone
'this works fine and populates the control.
End If
.
.
.
End Sub
'When the add button is clicked this sub fires
Public Sub add_phonecall(ByVal s As Object, ByVal e As ImageClickEventArgs)
.
.
'this section fires on postback
If IsNothing(ClientDetails) then
update_error.text = "No Client Details"
Exit Sub
End If
'this line gives the Object Reference Error if I remove the section above
note.visitorref = ClientDetails.visitorref
Any ideas how I maintain the ClientDetails instance in the custom control on a postback?
richyrich, September 22nd, 2008 03:24 PM
Bookmarks