p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 (http://p2p.wrox.com/forumdisplay.php?f=389)
-   -   ASP Wizard on Master Page (http://p2p.wrox.com/showthread.php?t=68605)

AspNetGuy June 4th, 2008 07:28 PM

ASP Wizard on Master Page
When I take a very simple example of a Wizard control which works on a non-master page and move the control to a page using a master page it cesases to work as follows:

If I have three steps, I can click the NEXT button on step 1 and move to STEP2. When I click on the NEXT button on the step 2 page the control remains on the current page.

If I click the PREVIOUS button on page 2 I get the following message:

Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorExceptio n: The command 'MovePrevious' is not valid for the previous step, make sure the step type is not changed between postbacks.

My master page is effectively the same as from Beginning ASP 3.5.

Any help would be greatly appreciated.

I have seen several references on the web to this message but no one has proposed a solution other than looking at the code behind file.

For this page there is no code in the code behind file. The BasePage code follows:

using System;
using System.Web;

/// <summary>
/// Summary description for BasePage
/// </summary>
public class BasePage : System.Web.UI.Page
    private void Page_PreRender(object sender, EventArgs e)
        if (this.Title == "Untitled Page")
            throw new Exception("Page title cannot be \"Untitled Page\".");

    private void Page_PreInit(object sender, EventArgs e)
        HttpCookie preferredTheme = Request.Cookies.Get("PreferredTheme");

        /* Obtain the URL.Segments for the current page*/
        string[] segments = Request.Url.Segments;

        /* Loop through the segments looking for "Security/". If found then */
        /* the user is requesting a page from the Security directory. We will*/
        /* always use the "Security" theme for those pages. */
        int i = 0;
        while (i < segments.Length && !segments[i].Equals("Security/"))
        if (i < segments.Length)
            Page.Theme = "Security";
            //if (preferredTheme != null)
            // preferredTheme.Value = "Security";
           // if (preferredTheme != null)
           // {
               // if (preferredTheme.Value == "DarkGrey")
               // {
               // preferredTheme.Value = "TFL";
               // }
               Page.Theme = "TFL";
           // }

    public BasePage()
        this.PreRender += new EventHandler(Page_PreRender);
        this.PreInit += new EventHandler(Page_PreInit);

AspNetGuy June 4th, 2008 09:19 PM

I have an update to this problem. If I create a new master page with no code in the code behind file the control works.

So it must be something in the code I posted earlier in the BasePage class.

AspNetGuy June 4th, 2008 09:34 PM

Ok I solved this problem. I don't understand why this one line of code broke the Wizard control and I certainly don't know why commenting it out fixes it, but it does.

In my base class (BasePage) for the master page I am suing I have the following code:

protected void Page_Load(object sender, EventArgs e)
        /* We do this to stabilize the prefix on IDs in the page. Now all IDs will */
        /* always start with "swdMaster". */
        this.ID = "swdMaster";

If I comment out that line of code my Wizard control works. IF I leave it in I get the results previously posted.

I hope this helps anyone else experiencing the problem.

planoie June 5th, 2008 09:19 AM

The error message you posted has to do with the AJAX framework, not so much with master pages. So I imagine that the problem with your line of code has to do with the way page callbacks are handled. Perhaps try setting a breakpoint on that line of code and see in what cases it gets called. Perhaps it's not getting called on an AJAX callback, although I don't see why that would be.


All times are GMT -4. The time now is 02:41 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.