Create Control

Posted by Community Admin on 04-Aug-2018 13:16

Create Control

All Replies

Posted by Community Admin on 07-Sep-2011 00:00

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.

Posted by Community Admin on 07-Sep-2011 00:00

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.

This thread is closed