Generate web controls programitically

G

Guest

This is basically repost of my previous (unanswered) question.
What I try to do is to generate Web controls on the Page surface during
design time from withing my own component; they do appear in the code behind
but not on the surface of Designer. Moreover, they DO exist in
container.Components collection.

May be someone knows (at least) how to make a control to generate it's own
html design time code (this <of type <asp:...>, not HTML rendering...)?

<repost starts here>

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,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top