Yesterday I’ve found out about one of the new features of .NET 3.5 SP1: the renderAllHiddenFieldsAtTopOfForm setting which allows you to control where in the page the hidden fields are being rendered. Today I gave it a shot in combination with a SharePoint Web Content Management solution…
The RenderAllHiddenFieldsAtTopOfForm has been added to the .NET framework as a solution for some postback related problems when users would trigger the postback before the page was fully rendered.
Steve Smith has presented on his blog a slightly different usage of that functionality: to move the hidden fields to the bottom of the page to improve the page for the search engines. Providing the most relevant content first is a commonly known search engine optimization.
SharePoint 2007 produces on average a few kilobytes of hidden fields markup on top of each page. These fields are used to store some internal information: from ViewState to SharePoint internal stuff. In general none of these is relevant neither to the users visiting your site nor a search engine indexing your content. Moving the hidden fields markup to the bottom of the page might help you improve the ranking of your web site. However…
Does renderAllHiddenFieldsAtTopOfForm really work?
Assuming the renderAllHiddenFieldsAtTopOfForm setting worked as Steve described I’ve been curious whether there was a performance penalty for moving away from the standard way how ASP.NET renders web pages. The first thing I did was to check it out on a SharePoint WCM solution I’ve been working at the moment. To setup the Web Application for .NET 3.5 I’ve followed Jan’s lazy approach. The hidden fields were still on top of the page!
Quite surprised I have tried the same approach with an empty Web Application. No matter the renderAllHiddenFieldsAtTopOfForm setting the hidden fields remained on top of the body HTML.
After having a closer look at the HTML rendered by SharePoint I’ve found out that the only field being moved is __EVENTVALIDATION. All other fields remain at the top of the page untouched. So unless there is something else you have to configure in order to get it working, it doesn’t seem like renderAllHiddenFieldsAtTopOfForm is of much help.
The MSDN reference page of the RenderAllHiddenFieldsAtTheTopOfForm property describes the working of the property as moving all the hidden fields to the top of the page to fix some postback problems. The way it’s described you could easily misinterpret it. The setting actually doesn’t allow you to define where to render the hidden fields. All it says is: if you want to I can put all hidden fields on the top of the page… That’s all.
Although it’s a bit disappointing to see that it doesn’t work as we hoped it would, it would be cool if such a functionality was added to ASP.NET. It would give us some extra control on how pages are being rendered. In the meanwhile: let’s keep on hacking to move these hidden fields around…
Technorati Tags: ASP.NET, SharePoint, Search Engine Optimization, WCM