Controls Disappear: MasterPage, LinkButton & SiteMapPath Debugging

Last post 09-10-2005 11:25 PM by clintonG. 3 replies.

Sort Posts:

  • Controls Disappear: MasterPage, LinkButton & SiteMapPath Debugging

    09-01-2005, 7:16 PM
    • Participant
      976 point Participant
    • clintonG
    • Member since 06-14-2002, 5:02 PM
    • Milwaukee County, Wisconsin, USA
    • Posts 238

    In the MasterPage I've used a control (LinkButton1) in the 'header' region to function as a tab that when clicked will display another control (LinkButton2). LinkButton2 is located within a panel (Panel1) which allows me toggle visibility on and off using click events.

    When LinkButton2 is clicked it loads content as expected but LinkButton2 also disappears when it is clicked after the page is posted back which must occur when a content page is loaded into the MasterPage ContentPlaceHolder.

    LinkButton2 appears in the Trace control tree and when displayed by a LinkButton1 click event LinkButton1 has Render Size and View State size values. When LinkButton2 is clicked to load the content it disappears as I've explained and its Render Size and View State values are zeroed out of the Trace control tree.

    I've tried the FindControl method and creating a Property both of which will return values for the LinkButton2.ID and LinkButton2.NamingContainer but I can not access or set LinkButton2.Visibility or other properties because the control has somehow disappeared. A similar behavior occurs with the SiteMapPath.

    What could I be missing?

    <%= clintonG
  • Re: Controls Disappear: MasterPage, LinkButton & SiteMapPath Debugging

    09-07-2005, 10:52 AM
    • Contributor
      4,347 point Contributor
    • dannychen
    • Member since 08-24-2004, 12:17 PM
    • Redmond, WA
    • Posts 840
    • AspNetTeam
      Moderator
    It sounds like you are clicking a link on the page that takes you to another page which happens to use the same masterpage.  In that case, you are navigating and not posting back.  To show this, create a copy of your master page and change some of the content and then assign that as the masterpage to your 2nd page. 

    Since it's a navigation action and not a postback, your entire page will load from scratch and not by postback.  That means the visibility of LinkButton2 will revert to it's default behavior. 
    --
    Danny
    disclaimer: Information provided is 'as is' and conveys no warranties or guarantees.
  • Re: Controls Disappear: MasterPage, LinkButton & SiteMapPath Debugging

    09-07-2005, 5:53 PM
    • Participant
      976 point Participant
    • clintonG
    • Member since 06-14-2002, 5:02 PM
    • Milwaukee County, Wisconsin, USA
    • Posts 238

    Hello - it sounds like you are correct but the PostBack tests are confusing.

    I ran the following PostBack tests...

    // Page_Load MasterPage.cs
            if(IsPostBack)
                Response.Write("MasterPage: WasPostBack");

            if(!IsPostBack)
                Response.Write("MasterPage: WasNotPostBack");

    // Page_Load ContentPage.cs
            if(IsPostBack)
                Response.Write("ContentPage: WasPostBack");

            if(!IsPostBack)
                Response.Write("ContentPage: WasNotPostBack");

    // Returned when HomePage.aspx loads the first instance of the MasterPage  
                MasterPage: WasNotPostBack

    // Returned when LinkButton1 is used to set Panel1.Visible = true displaying LinkButton2  
                MasterPage: WasPostBack

    // Returned when LinkButton2 click event is raised and Panel1/LinkButton1 dissapear
                ContentPage: WasNotPostBack
                MasterPage: WasNotPostBack

    Background Information:

    The LinkButton2 PostBackUrl = "~/dir/contentpage.aspx" property is set in the Page_Load event of the MasterPage. 
    When the LinkButton2 click event is raised from the MasterPage the value of the PostBackUrl property loads the content page. I do not know the internal navigation page transfer mechanism used when the PostBackUrl property is set.  I'm assuming it is the Server.Transfer method which I was using directly in the LinkButton2 click event before trying to use the PostBackUrl.

    How could the content page load if there is no PostBack?

    What can I try next?

    <%= clintonG
  • Re: Controls Disappear: MasterPage, LinkButton & SiteMapPath Debugging

    09-10-2005, 11:25 PM
    • Participant
      976 point Participant
    • clintonG
    • Member since 06-14-2002, 5:02 PM
    • Milwaukee County, Wisconsin, USA
    • Posts 238
    I'm killing this topic for lack of support.
    I've chosen to use the new menu control for navigation.
    <%= clintonG
Page 1 of 1 (4 items)