Try our conversational search powered by Generative AI!

Accessing XForm controls

Vote:
 
When i'm access controls in XForms everythis works fine except when i'm using the "Enabled property". Is there anyone who can figure out why my controls wont be disabled when i set the Enabled property to "false". Here is the code. private void SetFormMode(bool isEnabled) { System.Collections.ArrayList al = FormControl.ExtractXFormControls(); for (int i = 0; i < al.Count; i++) { if (al[i].GetType() == typeof(EPiServer.XForms.WebControls.Input)) { EPiServer.XForms.WebControls.Input input = (EPiServer.XForms.WebControls.Input)al[i]; input.Enabled = isEnabled; } if (al[i].GetType() == typeof(EPiServer.XForms.WebControls.Label)) { EPiServer.XForms.WebControls.Label label = (EPiServer.XForms.WebControls.Label)al[i]; label.Enabled = isEnabled; } if (al[i].GetType() == typeof(EPiServer.XForms.WebControls.Select)) { EPiServer.XForms.WebControls.Select select = (EPiServer.XForms.WebControls.Select)al[i]; select.Enabled = isEnabled; } if (al[i].GetType() == typeof(EPiServer.XForms.WebControls.Select1)) { EPiServer.XForms.WebControls.Select1 select1 = (EPiServer.XForms.WebControls.Select1)al[i]; select1.Enabled = isEnabled; } if (al[i].GetType() == typeof(EPiServer.XForms.WebControls.SelectControl)) { EPiServer.XForms.WebControls.SelectControl selectControl = (EPiServer.XForms.WebControls.SelectControl)al[i]; selectControl.Enabled = isEnabled; } if (al[i].GetType() == typeof(EPiServer.XForms.WebControls.Text)) { EPiServer.XForms.WebControls.Text text = (EPiServer.XForms.WebControls.Text)al[i]; text.Enabled = isEnabled; } if (al[i].GetType() == typeof(EPiServer.XForms.WebControls.TextArea)) { EPiServer.XForms.WebControls.TextArea textArea = (EPiServer.XForms.WebControls.TextArea)al[i]; textArea.Enabled = isEnabled; } if (al[i].GetType() == typeof(EPiServer.XForms.WebControls.Submit)) { EPiServer.XForms.WebControls.Submit submit = (EPiServer.XForms.WebControls.Submit)al[i]; submit.Enabled = isEnabled; } } }
#13178
Aug 24, 2007 14:27
Vote:
 
Use the Attributes property of control the behaviour of the desired control instead, ie control.Attributes.Add("readonly", "readonly") or if textarea control.Attributes.Add("disabled", "disabled").
#15500
Nov 01, 2007 19:32
Vote:
 
Thanks!
#15501
Nov 28, 2007 13:24
Vote:
 

Hi Benny,

While i am using your code it is giving error in the line

 System.Collections.ArrayList al = FormControl.ExtractXFormControls();

stating that [FormControl does not exist in the current context]

Can u figure out how to overcome this?

#52159
Jul 08, 2011 13:50
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.