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!
ping back from http://www.castorsoft.com/articles/2008.3.3.htm
ReplyDeleteHi Ronald,
ReplyDeleteI 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.
Thanks