make sure you call that code every time page load event fires.
If you inspect the html with Firebug after each postback, look at the form action, if the form action is changed it causes this error, the code is designed to make sure form action stays the same.
However, it only works in .NET 3.5 SP1 or higher, it will not work in .NET 3.5 without the service pak.