Thursday 24 April 2008

Postback opens layout rather than the Sitecore item

This was a weird one. I created a Sitecore item with layout and a sublayout. Then I placed a Button control on the sublayout and adding a click event handler that did something simple like display "Hello World" in a label on the sublayout. However, clicking the button navigated to the layout, rather than posting back to the Sitecore item. A colleague searched the Sitecore forum and eventually sorted the problem. It was due to the following line being commented out in the Form.browser file:
<adapter controlType="System.Web.UI.HtmlControls.HtmlForm"
adapterType="Sitecore.Web.FormAdapter, Sitecore.Kernel" />

I had commented this out due to runtime exceptions I was getting that referred to this line in the file. However, it now seems perfectly happy with it left in!

The file exists in the App_Browsers folder in the web site root. If it isn’t there, copy it from a clean 5.3.1 installation.

[Edited 30/7/2008]

And thanks to my colleague Jason Linham for noting further that the folder should not be hidden.

[Updated 16/9/2008]

1 comment:

Unknown said...

adapter controlType="System.Web.UI.HtmlControls.HtmlForm"
adapterType="Sitecore.Web.FormAdapter, Sitecore.Kernel"

This line caused problems to me when I mixed dll-s from Sitecore 5.3.0 and 5.3.1 versions. Mixing dlls of different versions is strongly unadvised, of course. :)