Home All Groups Group Topic Archive Search About

Dynamically Loading the User Control and Passing Parameters to it.

Author
24 Nov 2005 6:33 AM
Jamil
Hello,

I am loading the user control daynamically using
Page.LoadControl('mycontrol.ascx").
But with this i can not get my datamember's properties.
For example i declare a private integer variable
then i write a property to get or set the value of that private integer
variable.
But with the above method i can'nt get that property.

the second way is to create the object of mycontrol class and then add it in
the page.controls collection.
but with this it did not show the controls of user control like textboxes
and buttons.

Reply me soon please....

Regards,
Muhammad Jamil Nawaz

Author
24 Nov 2005 8:37 AM
HP
Hi Jamil,

The Page.LoadControl() method returns the control object. So if you wish to
access some of the properties of your control you can do the follwing,

Dim m as MyControl

m = CType(Page.LoadControl("MyControl.ascx"), MyControl)
m.Property1
...

Hope that helps.

Regards,
HP

Show quoteHide quote
"Jamil" wrote:

> Hello,
>
> I am loading the user control daynamically using
> Page.LoadControl('mycontrol.ascx").
> But with this i can not get my datamember's properties.
> For example i declare a private integer variable
> then i write a property to get or set the value of that private integer
> variable.
> But with the above method i can'nt get that property.
>
> the second way is to create the object of mycontrol class and then add it in
> the page.controls collection.
> but with this it did not show the controls of user control like textboxes
> and buttons.
>
> Reply me soon please....
>
> Regards,
> Muhammad Jamil Nawaz
>
>
>

Bookmark and Share