ASP.NET 2.0 and MCMS – glitches with navigation controls when switching between modes


When switching from published mode to edit mode using a template that holds the ASP.NET 2.0 navigation controls using the MCMS Site Map Provider will show an unwanted behaviour: the navigation controls will continue to show the published mode URLs. This is being caused by the fact that these controls buffer the information in viewstate. Due to the fact that switching between published and unpublished mode will cause a postback this information is being preserved.


So it is required to clear the viewstate of the navigation controls when switching between edit mode and published mode – or just to disable viewstate in unpublished mode completly and only to enable it in published mode.


In my code I added the following code to the Page_Load event to ensure that the navigation controls always show the correct links:


    protected void Page_Load(object sender, EventArgs e) 
   
        bool enableViewState = (WebAuthorContext.Current.Mode == WebAuthorContextMode.PresentationPublished); 
        this.TreeView1.EnableViewState = enableViewState; 
        this.Menu1.EnableViewState = enableViewState; 
    }

Comments (5)

  1. AndrewSeven says:

    I’ve wondered why switching to and from Edit Mode is done with a postback.

    There are significant differences of context similar to navigation and it doesn’t seem to need to be a postback.

    I’ve encountered some (not so good) controls that have viewstate issues because there are different items available in edit mode than in live mode.

  2. Anonymous says:

    In my previous article I have discussed how to implement site navigation for an MCMS site using ASP.NET…

  3. Anonymous says:

    In my previous article I have discussed how to implement site navigation for an MCMS site using ASP.NET…

  4. Anonymous says:

    In my previous article I have discussed how to implement site navigation for an MCMS site using ASP.NET…

  5. Anonymous says:

    Now after MCMS 2002 SP2 has been released I would like to point you again to an article series I have…