P
Peter Young
I would like to add a control to the aspx page that my control is sited on, programmatically at design time.
I understand that IDesignerHost.CreateComponent is the method to use, and it appears to add the control to some extent,
but the control never appears on the design surface, and also does not persist.
Here's the test code:
IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));
TextBox textBox1 = host.CreateComponent(typeof(TextBox)) as TextBox;
textBox1.Text = "hello";
The result of running this is the properties window's dropdown shows the textbox, and the Text property is correct. The
code-behind also shows the textbox is declared. But the textbox never shows on the design surface, never shows in the
html, and once you switch to html view, then back to design view, the control is gone.
What am I missing here?
TIA,
Pete
I understand that IDesignerHost.CreateComponent is the method to use, and it appears to add the control to some extent,
but the control never appears on the design surface, and also does not persist.
Here's the test code:
IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));
TextBox textBox1 = host.CreateComponent(typeof(TextBox)) as TextBox;
textBox1.Text = "hello";
The result of running this is the properties window's dropdown shows the textbox, and the Text property is correct. The
code-behind also shows the textbox is declared. But the textbox never shows on the design surface, never shows in the
html, and once you switch to html view, then back to design view, the control is gone.
What am I missing here?
TIA,
Pete