Drop-down list data source displaying error when selected as a form control in web part properties

Novice User asked on April 16, 2020 17:35

I am creating a web part , for my property when I am selecting dropdownlist as a form control, data source does not display list of option, macro expression, sql query. Instead it displays error as

[Error loading the FormControl 'optionsselector'] Unable to cast object of type 'ASP.cmsformcontrols_system_optionsselector_ascx' to type 'CMS.FormControls.FormEngineUserControl'.

I am using kentico version 9.

Any insight will help.

Correct Answer

Brenden Kehren answered on April 16, 2020 19:05

I'd suggest checking the event log and getting the specific error details. It could be multiple things but I'd suggest starting with the event log. Next look at the following:

  • compare a base /CMSFormControls/System/OptionSelector.ascx.cs file with what you have. This is where the issue resides based on your error text Unable to cast object of type 'ASP.cmsformcontrols_system_optionsselector_ascx' to type 'CMS.FormControls.FormEngineUserControl
  • make sure there aren't 2 OptionSelector.ascx files or code files in the file system. Seen it too many times devs copy a file but don't modify the classname and never build the project so they don't find the error.
  • build your project and see if you come up with any errors.
1 votesVote for this answer Unmark Correct answer

Recent Answers


Peter Mogilnitski answered on April 16, 2020 18:17

did you inherit your options selection from FormEngineUserControl?

public partial class CMSFormControls_optionsselection : FormEngineUserControl

1 votesVote for this answer Mark as a Correct answer

Novice User answered on April 16, 2020 18:28 (last edited on April 16, 2020 18:37)

The error is being displayed on the property tab in web part module. I have checked the control file which is inheriting

public partial class CMSFormControls_Basic_DropDownListControl : ListFormControl

Any other file I need to check ?

https://imgur.com/a/FaAR77b

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on April 16, 2020 18:59

Dont use drop-down list there for your data source. Try using options selector control: Image Text

0 votesVote for this answer Mark as a Correct answer

Novice User answered on April 16, 2020 19:45

Hi ,

/CMSFormControls/System/OptionSelector.ascx.cs file was empty. I replaced it with appropriate code from previous file and the error was gone.

I checked there is no option selector in my form control.

Thanks Brendon and Peter for all your help and pointers.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.