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; 
    }

5 Comments


  1. 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.

    Reply

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

    Reply

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

    Reply

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

    Reply

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

    Reply

Leave a Reply to Anonymous Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.