Object reference not set to an instance of an object.

Last post 01-09-2008 10:56 AM by isyan. 8 replies.

Sort Posts:

  • Object reference not set to an instance of an object.

    01-09-2008, 9:04 AM
    • Loading...
    • isyan
    • Joined on 08-06-2007, 12:46 AM
    • Posts 44

    I have an updatepanel(named UpdatePanelSignup) inside another updatepanel(named UpdatePanelBusiness)...

    UpdatePanelBusiness is set initially to visible=false... 

    I also have a dropdownlist(named dropdownlistbusiness) inside UpdatePanelSignup...

    I have two choices for the dropdownlist... Yes and No...

    I want to make the UpdatePanelBusiness visible when I choose Yes in the dropdownlistbusiness...

    Here's the code.. but it creates an exception which is the subject of this post... 

     

     Dim objdropdown As New DropDownList
            objdropdown = UpdatePanelSignup.FindControl("dropdownlistbusiness")

                If objdropdown.SelectedValue = "Yes" Then
                    UpdatePanelSignup.FindControl("updatepanelbusiness").Visible = False
                ElseIf objdropdown.SelectedValue = "No" Then
                    UpdatePanelSignup.FindControl("updatepanelbusiness").Visible = True
                End If

    Please Convert your snippet to VB... Thanks!
  • Re: Object reference not set to an instance of an object.

    01-09-2008, 9:15 AM
    Answer
    • Loading...
    • tfsmag
    • Joined on 01-06-2006, 5:58 PM
    • Danville, Illinois
    • Posts 486

     I guess first I'd have to question why you have nested updatepanels. The first panel will refresh without postback when you perform an action inside of the updatepanel (as long as childrenastriggers is set to true). Could you not do a server side div rather than a second update panel?

    <!--inside of main update panel-->

    <div id="divPanel" runat="server" visible="false">

    -- content

    </div>

    then on the dropdownlists selected item event toggle the div to visible.

    Also as far as I know items inside of an update panel can be called just like any other control on the normal page, you don't need to do a updatepanel.findcontrol. 

    ------------------------------------------------
    Jeff Turner (simpleModus)

    Don't forget to mark the correct answer for your
    question to help out future visitors!
  • Re: Object reference not set to an instance of an object.

    01-09-2008, 9:52 AM
    • Loading...
    • isyan
    • Joined on 08-06-2007, 12:46 AM
    • Posts 44

     thanks! I changed the updatepanel to div and the visible property works... Wink

    another question... 

    how do I access a dropdownlist in side an updatepanel?

    Please Convert your snippet to VB... Thanks!
  • Re: Object reference not set to an instance of an object.

    01-09-2008, 9:55 AM
    • Loading...
    • tfsmag
    • Joined on 01-06-2006, 5:58 PM
    • Danville, Illinois
    • Posts 486

     you'd access it the same way you would if you didn't have it inside of an update panel. Just call it by ID in your codebehind.

    ------------------------------------------------
    Jeff Turner (simpleModus)

    Don't forget to mark the correct answer for your
    question to help out future visitors!
  • Re: Object reference not set to an instance of an object.

    01-09-2008, 10:04 AM
    • Loading...
    • isyan
    • Joined on 08-06-2007, 12:46 AM
    • Posts 44

     it doesn't appear on the intelisense...

     

    Please Convert your snippet to VB... Thanks!
  • Re: Object reference not set to an instance of an object.

    01-09-2008, 10:14 AM
    • Loading...
    • tfsmag
    • Joined on 01-06-2006, 5:58 PM
    • Danville, Illinois
    • Posts 486

     that happens sometimes to me... try typing it in or copying and pasting the id in and running the code.

    ------------------------------------------------
    Jeff Turner (simpleModus)

    Don't forget to mark the correct answer for your
    question to help out future visitors!
  • Re: Object reference not set to an instance of an object.

    01-09-2008, 10:32 AM
    • Loading...
    • isyan
    • Joined on 08-06-2007, 12:46 AM
    • Posts 44

     it creates an error

    BC30451: Name 'dropdownlistbusiness' is not declared.

    Please Convert your snippet to VB... Thanks!
  • Re: Object reference not set to an instance of an object.

    01-09-2008, 10:52 AM
    • Loading...
    • tfsmag
    • Joined on 01-06-2006, 5:58 PM
    • Danville, Illinois
    • Posts 486

     is your updatepanel inside of another container? If so you'll have to do the findcontrol from that container and not from the updatepanel.

    ------------------------------------------------
    Jeff Turner (simpleModus)

    Don't forget to mark the correct answer for your
    question to help out future visitors!
  • Re: Object reference not set to an instance of an object.

    01-09-2008, 10:56 AM
    • Loading...
    • isyan
    • Joined on 08-06-2007, 12:46 AM
    • Posts 44

    i forgot to tell you that inside the updatepanel is a createuserwizard...

    the div is inside the createuserwizard...
     

    Please Convert your snippet to VB... Thanks!
Page 1 of 1 (9 items)
Microsoft Communities
Page view counter