More in this section

Forums / Developing with Sitefinity / Programatically register usercontrols with sitefinity

Programatically register usercontrols with sitefinity

2 posts, 0 answered
  1. Adeel Arif
    Adeel Arif avatar
    27 posts
    30 Dec 2009
    25 Jan 2010
    Link to this post
    Hi folks hope you are all fine ,
    I have a requirement that i have to register the usercontrols  that i make into sitefinity programatically, to be precise i want a widget  like functionality on my page that i can at the run time remove a control on users request and add new user controls that are already programmed and are generic in type....
    Thank you waiting anxiously for your reply.

    Adeel Arif.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    25 Jan 2010
    Link to this post
    Hello Adeel Arif,

    Please take a look at this KB that shows how to add controls on a page programmatically - How to create predefined template pages that contain controls placed on the content areas . To delete a control you can use the code shown below

    ICmsPage page = (ICmsPage)Manager.GetPage(cmsPage.ID, true);
    IStagedPage staged = page.Staged as IStagedPage;
    foreach (ICmsWebControl control in staged.Controls)
        if (control.ControlType.Name == "SomeControl")
            page = (ICmsPage)Manager.GetPage(page.ID, true);

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
2 posts, 0 answered