Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Documentation and Tutorials > Unable to cast object of type 'Telerik.Web.UI.RadMultiPage' to type 'System.Web.UI.UserControl'.

Not answered Unable to cast object of type 'Telerik.Web.UI.RadMultiPage' to type 'System.Web.UI.UserControl'.

Feed from this thread
  • Posted on Jan 10, 2012 (permalink)

    error: Unable to cast object of type 'Telerik.Web.UI.RadMultiPage' to type 'System.Web.UI.UserControl'.

    When going through a user control for a EditFormUserControl and I wanted to list all the user controls on that page but doing a foreach loop I need a fairly consistent type to iterate through.  So how can I iterate through 'userControl' when it could be a lteral for a label or  a 'RadMultiPage' or a 'UserControl'.  I have tried ...string objectTypeName="RadMultiPage";

     

    Type

     

    T = Type

     

    .GetType(objectTypeName);

     

    ((

    typeof(T)))userControl).Controls

     

     

    But I just wanter to be able to have a reursive call listing out all the children be them Usercontrol or Telerik User controls. 
    Any Ideas ?
    Doug

     

     

     

    UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);

    foreach

     

    (object uc in ((UserControl)userControl).Controls){}

     

    Reply

  • Kate Kate admin's avatar

    Posted on Jan 13, 2012 (permalink)

    Hi Doug,

    Please refer to the following forum post that might give you a clearer understanding of how you can achieve the desired behavior:

    • http://forums.asp.net/t/1726687.aspx/1
    • http://stackoverflow.com/questions/3834544/loop-through-controls-of-a-usercontrol
    • http://stackoverflow.com/questions/2632302/loop-through-all-the-user-controls-on-a-page
    • http://aspmessageboard.com/showthread.php?t=161740

    Kind regards,
    Kate
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Documentation and Tutorials > Unable to cast object of type 'Telerik.Web.UI.RadMultiPage' to type 'System.Web.UI.UserControl'.