Thanks,
The reason I want to use the second example is that myUserControl should
load different values, depending on an external source identified by a
string.
So, I want to use the generic myUserControl to be reused over and over
again.
I already got it working with LoadControl().
What I do is:
In the containing Page (Test.aspx)
Create the UserControl with LoadControl
Then I put the newly loaded control into an Hash (control is the key),
an identifying string the value
Then I add the control to a PlaceHolder.
In this page I write a methode which will return the string when the
control is given as argument
In myUserControl
In PageLoad, I try to find the containing Page (test.aspx)
Cast the found page to Test
Call a methode on the Test instance with 'this' as argument
With the retrieved string, I can get a specific field/table from e.g. a
database
But I rather have it working without the callback from the ChildControl.
Ben
"John Saunders" <jo************ **@notcoldmail. com> wrote in message
news:eM******** ******@TK2MSFTN GP11.phx.gbl...
"Ben de Vette" <Be************ ****@profiler.n l> wrote in message
news:10******** *****@corp.supe rnews.com... Hi,
I like to load a UserControl onto a placeholder with some more control then just doing
protected System.Web.UI.W ebControls.Plac eHolder placeHolder;
UserControl ascx =
(UserControl)Pa ge.LoadControl( "myUserControl. ascx"); placeHolder.Con trols.Add(ascx) ;
More something like
UserControl uc = new myUserContol();
uc.Name = "just A Test";
uc.Initialize() ;
placeHolder.Con tols.Add(uc);
The problem lies in the fact that any contols placed in myUserControl
are not instanciated in the second example. Any idea how I get this working?
When you use LoadControl, the HTML in the .ascx file are compiled. They
are compiled into a class which inherits from the myUserControl class. The
..ascx file isn't touched in your second case.
Is there a reason why you can't use the first way?
--
John Saunders
johnwsaundersii i at hotmail