Unable to cast object of type 'ASP.cmswebparts_hdy_medialistingfilter_ascx' to type 'CMS.PortalContr

Sultan Ahmed asked on March 19, 2015 04:23

I am trying to create a custom filter and i am getting the following error message in event log can you please tell me where i am wrong? or what is the problem,

Message: Unable to cast object of type 'ASP.cmswebparts_hdy_medialistingfilter_ascx' to type 'CMS.PortalControls.CMSAbstractWebPart'.

Exception type: System.InvalidCastException Stack Trace: at CMS.PortalControls.CMSWebPartZone.LoadWebPart(Control container, CMSWebPartZone zone, WebPartInstance part, Boolean reloadData, Boolean isVariant)

Message: Unable to cast object of type 'ASP.cmswebparts_hdy_medialistingfilter_ascx' to type 'CMS.PortalControls.CMSAbstractWebPart'.

Exception type: System.InvalidCastException Stack Trace: at CMS.PortalControls.CMSWebPartZone.LoadWebPart(Control container, CMSWebPartZone zone, WebPartInstance part, Boolean reloadData, Boolean isVariant)

Recent Answers


Virgil Carroll answered on March 19, 2015 13:29

Sounds like you have something wrong with the class declaration for the code behind in the user control.

Did you add the using CMS.PortalEngine; to the top declaration? and inherit from one of these classes?: CMSAbstractDataFilterControl CMSAbstractMenuFilterControl CMSAbstractQueryFilterControl

Check out this article here: https://docs.kentico.com/display/K8/Developing+custom+filters

If you are using an earlier version than 8 then you might need to inherit from the CMSAbstractBaseFilterControl class.

0 votesVote for this answer Mark as a Correct answer

paul krysiak answered on October 25, 2017 01:58

Did this ever get resolved? I am having the same issue with 9.

0 votesVote for this answer Mark as a Correct answer

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