DeveloperBarn Forums

DeveloperBarn

Programming & IT forum

Object Reference Error on Custom Control Postback

This is a discussion on Object Reference Error on Custom Control Postback within the .Net Development forums, part of the Programming & Scripting category; I have a main page that contains a repeater control. In the first column, each entry has a radio button. ...

Go Back   DeveloperBarn Forums > Programming & Scripting > .Net Development

  #1  
Old September 22nd, 2008, 03:24 PM
richyrich's Avatar
Administrator
 
Join Date: Mar 2008
Real name: Rich
Location: Somewhere only we know...
Posts: 1,345
Blog Entries: 6
Rep Power: 8
richyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to all
Default 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?
Reply With Quote
  #2  
Old September 22nd, 2008, 05:56 PM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Real name: Jason
Location: Washington, D.C.
Posts: 1,964
Blog Entries: 8
Rep Power: 15
jmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud of
Default

You could always store the values in viewstate...
__________________
jmurrayhead
If you agree with me... click the icon!
If my post solved your problem, click the button in the lower right-hand corner of the post.

If you like it here...throw us a few bones to help
support us.

Join our Folding team: DeveloperBarn Folding

Reply With Quote
Reply

  DeveloperBarn Forums > Programming & Scripting > .Net Development

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
Custom Calendar Control AOG123 Access Database Samples 6 December 10th, 2008 05:34 PM
[ASP.Net - Web Controls] reference control from nested repeater Shem .Net Development 18 September 15th, 2008 10:46 AM
Object reference not set to an instance of an object Shem .Net Development 4 July 22nd, 2008 04:59 AM
Retrieving DataItem on Postback richyrich .Net Development 4 July 21st, 2008 10:15 AM
Object reference not set to an instance of an object jmurrayhead .Net Development 1 May 29th, 2008 10:16 AM


All times are GMT -4. The time now is 05:15 PM.


Copyright ©2008-2010, DeveloperBarn

Content Relevant URLs by vBSEO 3.3.2