UserControl injection sample.

Topics: Web Client Software Factory, User Forum
May 16, 2008 at 7:44 AM
Edited May 16, 2008 at 7:49 AM
Hi
Is there a simple UserControl injection sample availabe.
If not would any care to share a Helloworld Usercontrol example please.
Thanks.
May 16, 2008 at 12:47 PM


pathurun wrote:
Hi
Is there a simple UserControl injection sample availabe.
If not would any care to share a Helloworld Usercontrol example please.
Thanks.


I have tried this it seems to work. If this is the best practise i am not sure:

In the Default.aspx.cs 

protected

override void OnPreInit(EventArgs e)

 

{

 

base.OnPreInit(e);

 

 

string path = @"~/WebUserControl.ascx";

 

 

Control ctl = LoadControl(path);

 

 

 

WebClientApplication.BuildItemWithCurrentContext(ctl); 

 

 

this.Master.Controls[3].Controls[11].Controls.Add(ctl);

 

 

//this.Form.Controls.Add(ctl);

 

 

//this.Controls.Add(ctl);

 

 

}