DotNetNuke : MaintainScrollPositionOnPostback property can not be set without an html form

In ASP.NET 2.0 there is a simple new property in the System.Web.UI.Page object called 'MaintainScrollPositionOnPostback'.

When you set this property to 'true', javascript will be inserted in your rendered page that maintains the scroll position in the browser window for all postbacks.  Those of us who have done this manually, know that this is not rocket science to achieve, but its sooo nice to be able to set a single property to just 'make it happen'.  You can alse set this property in the web.config file to use it on all pages. 

<pages validateRequest="false" enableViewStateMac="true" enableEventValidation="false" maintainScrollPositionOnPostBack="true">

I used this property in several DotNetNuke (4.x.x) projects but ran into a major problem when logging off.  I always get the error 'The maintainScrollPositionOnPostback property can not be set without an html form'.  The standard home page will not be shown :-(

When logging off, dotnetnuke will redirect to a default logoff page located under Admin\Security\logoff.aspx
This is an empty page with only the Page_Load event used.  In this event, the user will be logged off from the cookie authentication system and the user will be redirected to the default home page.

To solve the error you only have to set the property to false in the page directive

<%@ Page MaintainScrollPositionOnPostback="false" language="vb" ...

This article is part of the GWB Archives. Original Author: Gert Verhoeven

New on Geeks with Blogs

  • We Won The One Award I Actually Care About

    Full Scale made the Inc. 5000 for the fifth year straight, the 12th listing across my three companies. Here is why the one award you cannot buy is worth stopping for.

  • Your Customers Build the Features Now

    I let a tool I liked sit dead for a year rather than build the features I wanted. An MCP server meant I never had to, and your customers can do the same to your product.

  • Get the Size of a Directory in Linux the Easy Way

    du -sh for the quick answer, ncdu for the cleanup, df for the disk itself: every command for checking directory size in Linux, plus why du and df never agree.

  • Vim Search and Replace: The Ultimate Guide

    One :%s command replaces every match in a file before a find dialog would even open. The Vim substitute patterns worth the muscle memory: flags, ranges, capture groups, and multi-file edits.