Monday, May 23, 2011

Viewstate is not maintained in iframe inside MS CRM form

We had a page that is hosted inside CRM form, the page contains list with a checkboxes beside each each row. When clicking apply, certain action should be performed on the selected items. things are working fine on the development machine, but when hosting inside the CRM form, when clicking “apply”, the action wasn’t applied on the selected items, we discovered later that the code that loops over the checked items, doesn’t run as if there is no records checked.

Doing some search I found that CRM web.config by default has the following line

enableViewState="false" i.e. by default Viewstate is not enabled in CRM.

Changing this to enableViewState="true" and restarting IIS, every thing worked fine and actions were applied successfully.

There is another option which is to enable this in the page directives like the following

<%@ Page Language="C#" ... EnableViewState="true" %>