1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Create Control

Create Control

2 posts, 1 answered
  1. Anton
    Anton avatar
    13 posts
    Registered:
    02 Aug 2011
    07 Sep 2011
    Link to this post
    Hi there!

    I want to add control to the page programmatically, but a have a problem:
    My Custom control is in another dll , and while calling CreateControl method I don't know what path must be specified.
    Can I specify path that is not in the root of my website?
    If so show me some example please.
  2. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    07 Sep 2011
    Link to this post
    It sounds like you are using a compiled widget from another dll as opposed to a simple widget (user control .ascx file).

    If that is the case, you don't pass the path to the control, you pass an instance of the control itself. As an example:

    var control = new NewsView();
    var pageControl = pageManager.CreateControl<PageControl>(control, placeHolder);
    page.Page.Controls.Add(pageControl);
    pageManager.SaveChanges();

    I hope this is helpful, let me know if I have misunderstood your question.
    Answered
2 posts, 1 answered