Design Time - cannot add control to web page using iDesignerHost

G

Guest

I try to add a textbox from code of my custom component laid on the web form.
It appears in the code behind but not in the designer; moreover when I switch
from design to html view it gets removed from the code-behind.
What interesting: when (by mistake) I tried to add Windows TextBox the code
added it to the component section of the designer (so "almost" desired
behaviour...)
Any ideas, please?

The code is based on MSDN example of component
ms-help://MS.VSCC.2003/MS.MSDNQTR.2004OCT.1033/cpref/html/frlrfSystemComponentModelDesignIDesignerHostClassTopic.htm
- I'm trying this code when user double-clicks component

IDesignerHost host =
(IDesignerHost)this.component.Site.GetService(typeof(IDesignerHost));
IComponent newItem =
host.CreateComponent(typeof(System.Web.UI.WebControls.TextBox), "txtNew");
//when this code used, works
//IComponent newItem =
host.CreateComponent(typeof(System.Windows.Forms.TextBox), "txtNew");
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top