Dynamically Loading the User Control and Passing Parameters to it.

J

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
 
G

Guest

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
 

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

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top