New Things in .NET 3.5 SP1 ' Moving Hidden Fields to the Bottom of the Page

If you have not downloaded SP1 for Visual Studio 2008 and .NET 3.5, please go ahead and get to it. If you installed the Beta, like me and many other folks you will want to run the prep tool first. I am not going to do one of those here is a list of new features in SP1, there are plenty of those all over the web by now. I mean SP1 has been out all week long. Instead I want to create some post showing some of the important features in more detail.

Over the years I have worked on moving ViewState and other Hidden Input Fields to the bottom of the page. This is important for several reasons, but can also have impact on some content, like the DevExpress HTML Editor. However, moving non rendered content helps the page render faster and also helps place important content higher in the page, thus allowing the search engines know the content is more important. So often it is wise to move Hidden Fields to the bottom of the page.

ASP.NET SP 1 has added a new property to the Page configuration section, RenderAllHiddenFieldsAtTopOfForm. This is a great new property that gives you control over where the system generated hidden fields are rendered by the framework or page handler creates. That is important to note, because the property will not affect any hidden fields you add to the markup, those will still need to be handled by you. Personally I do not think I ever use hidden fields, so it should not be an issue for me and most likely not you. While this will not move the ViewState hidden field it will render other generated hidden fields at the bottom.

<

pages

theme

="DarkBeer"

masterPageFile

="~/TBHMain.master"

maintainScrollPositionOnPostBack

="true"

renderAllHiddenFieldsAtTopOfForm

="false"

>

When this is an issue is when a a postback is performed before the page is completely rendered. This typically happens when an AJAX postback is performed as the page is being rendered. From my experience you have to test each of your pages to learn which ones will be affected. You will receive an 'Invalid Postback' or 'callback argument' error. Other things I have found is controls will not render correctly in some cases. I have found most of my problems are with third party controls, in particular WYSIWYG editors like FreeTextBox and the DevExpress HTML Editor.

<

div

>

<

input

type

="hidden"

name

="__SCROLLPOSITIONX"

id

="__SCROLLPOSITIONX"

value

="0"

/>

<

input

type

="hidden"

name

="__SCROLLPOSITIONY"

id

="__SCROLLPOSITIONY"

value

="0"

/>

<

input

type

="hidden"

name

="__EVENTVALIDATION"

id

="__EVENTVALIDATION"

value

="/wEWBwLjspyADQKP0anjBQK41pvTDwK0yq71CQLBo8n8...PKC"

/>

</

div

>

One thing to note is since this is done in the web.config Page element, this feature is applied to all pages and cannot be controlled at the page level. So if you have any issues with this and have to turn it off, beware this will affect all the pages in the web site.

Share This Article With Your Friends!

Googles Ads Facebook Pixel Bing Pixel LinkedIn Pixel