SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Learning...
    Join Date
    Jan 2003
    Posts
    781
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    making panel hide/show

    I have a panel that is on my master page. I need to show/hide on demand from my content page that is built from this master page.

    Master Page Code
    Code:
    Partial Class MasterPageTwoColumn
     	Inherits System.Web.UI.MasterPage
     
     	Public Function ShowHelpFulLinksPanel(ByVal value As Boolean) As Boolean
     		pnlHelpFulLinks.Visible = value
     	End Function
     
     End Class
    Content Page Code
    Code:
    Partial Class Default2
     	Inherits System.Web.UI.Page
     
     	Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
     		Dim MasterPageTwoColumn As New MasterPageTwoColumn
     		MasterPageTwoColumn.ShowHelpFulLinksPanel(False)
     	End Sub
     End Class
    when i do this, i actually get error on my master page code
    Code:
    pnlHelpFulLinks.Visible = value
    Error Message
    Code:
      Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
     
                    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
     
                   Source Error:Line 9:  
     Line 10:     Public Sub ShowHelpFulLinksPanel(ByVal value As Boolean)
     Line 11:         pnlHelpFulLinks.Visible = value
     Line 12:     End Sub
     
     Line 13:Stack Trace: 
                                                                             [NullReferenceException: Object reference not set to an instance of an object.]
        MasterPageTwoColumn.ShowHelpFulLinksPanel(Boolean value) in C:\Documents and Settings\Tahir.NRCCUA_HQ\Desktop\MCO\MasterPageTwoColumn.master.vb:11
        Default2.Page_Load(Object sender, EventArgs e) in C:\Documents and Settings\Tahir.NRCCUA_HQ\Desktop\MCO\Default2.aspx.vb:7
        System.Web.UI.Control.OnLoad(EventArgs e) +80
        System.Web.UI.Control.LoadRecursive() +49
        System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3745
    The beauty of life is not dependent on how happy you are,
    but on how happy others can be because of you...

  2. #2
    SitePoint Zealot yacka's Avatar
    Join Date
    Aug 2006
    Posts
    124
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I suspect the problem is in your Page_Load code. You are creating a new object instead of using the instance of the master used by your page. You should also check that the name your using for the panel in code is also the same that you have defined in the markup.

    I think you can do something like (haven't done vb for a while)

    Code:
     	Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
     		Dim theMasterPage As MasterPageTwoColumn
    		
    		theMasterPage = CType(Me.Master, MasterPageTwoColumn)
    
     		theMasterPage.ShowHelpFulLinksPanel(False)
     	End Sub

  3. #3
    Learning...
    Join Date
    Jan 2003
    Posts
    781
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks a lot, change from VB6 to ASP someyears ago and now back to VB, i need to think straight again.
    The beauty of life is not dependent on how happy you are,
    but on how happy others can be because of you...


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
  •