ForceSubmit in ASP.Net

Today I've been working on a simple IFrame. This IFrame shows 3 dynamic picklists and the data in these picklists is coming from crm. Since some clients are a bit slow, I would like the picklists to be disabled while the postback is being performed. This is easily done with this script:

function disableFields(field1, field2){
field1.disabled = true;
field2.disabled = true;

<asp:DropDownList ID="ddl1" runat="server" AutoPostBack="true" onchange="disableField(form1.ddl2, form1.ddl3);">
<asp:DropDownList ID="ddl2" runat="server" AutoPostBack="true" onchange="disableField(form1.ddl1, form1.ddl3);">
<asp:DropDownList ID="ddl3" runat="server" AutoPostBack="true" onchange="disableField(form1.ddl1, form1.ddl2);">

This works perfectly, but... After a postback, the values of the selected picklists are gone! This seems like the same behavior as the disabled fields in CRM. In CRM you can solve this by setting the attribute ForceSubmit to true on the attribute, but I did not know of such an attribute.

Apparently there is such behaviour built into ASP.NET 2.0. In order to enable the submission of disabled form elements, you need to put this line in the Page_Load:

Page.Form.SubmitDisabledControls = true;

For more information on this attribute, check MSDN

Happy disabling!


Anonymous said...

ping back from

Anonymous said...

Hi Ronald,

I am having a similiar problem with the disabled function. I have a picklist with 4 values and I also have 4 lookup's. On the onChange event of the picklist each lookup field will be disabled depending with item is chosen from the picklist. It all works on the onChange() event but as soon as I click save&close and reopen the record the fields are no longer disabled. I am using the ForceSubmit property but that does'nt seem to work.

Any help will be much appreciated.