+ Reply to Thread
Results 1 to 2 of 2

Thread: Object Reference Error on Custom Control Postback

  1. #1
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    1,724
    Blog Entries
    10
    Rep Power
    11

    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?

  2. #2
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Washington, D.C.
    Posts
    2,347
    Blog Entries
    9
    Rep Power
    19

    You could always store the values in viewstate...
    jmurrayhead
    If you agree, give me rep. If my post helped you, click "Thanks".
    If you like it here...throw us a few bones to help support us.


+ Reply to Thread

Similar Threads

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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO