This is a generic function to enable / disable all controls on a form from server-side, except for buttons. Call as LockForm(this, true) or LockForm(this, false). Watch out as values will be persisted between postbacks (e.g. when browsing through SalesLogix entities). Also, it won’t go through a main view tab.
/// <summary> /// Enable / disable all controls on the form /// </summary> /// <param name="islocked"></param> private void LockForm(Control parent, bool islocked) { foreach (Control c in parent.Controls) { if (c is IButtonControl || c is SmartPartToolsContainer) continue; if (c.Controls.Count > 0) LockForm(c, islocked); PropertyInfo pr = c.GetType().GetProperty("ReadOnly"); if (pr != null) { pr.SetValue(c, islocked, null); } else { pr = c.GetType().GetProperty("Enabled"); if (pr != null) { pr.SetValue(c, !islocked, null); } } } }