Sunday, November 4, 2007

Wizzard Control With Master Page Problem

I had a page that had a wizzard control and it worked fine. But after I've added a master page, it got the following error (when I click on the Next or Previous Button):

"The command 'MovePrevious' is not valid for the previous step, make sure the step type is not changed between postbacks".

When I debugged the page, I saw that always ActiveStepIndex = 0 and somehow it had been lost during the postback. The problem was that I had changed the ID of the master page on its Load event. That was the problem. When I changed it to use Init, not Load, everything got fine again. So, it is important to know exactly how the events are being raised. The order is the following:

Init (master page)
Init (page)
Load (page)
Load (master page)


You see that first is executed Load of the page and after that the Load event of the master page. And because I changed the ID of the master page on Load (it reflects the name of the controls in the page) the page lost its data.

Conclusion - be sure how the events are raised in page lifecycle.

PS: The bad thing was that I had to find it on my own. There's no info about that on the net.
eXTReMe Tracker