Dynamically Loading the User Control and Passing Parameters to it.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jamil

    Dynamically Loading the User Control and Passing Parameters to it.

    Hello,

    I am loading the user control daynamically using
    Page.LoadContro l('mycontrol.as cx").
    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


  • HP

    #2
    RE: Dynamically Loading the User Control and Passing Parameters to it.

    Hi Jamil,

    The Page.LoadContro l() 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.Load Control("MyCont rol.ascx"), MyControl)
    m.Property1
    ...

    Hope that helps.

    Regards,
    HP

    "Jamil" wrote:
    [color=blue]
    > Hello,
    >
    > I am loading the user control daynamically using
    > Page.LoadContro l('mycontrol.as cx").
    > 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
    >
    >
    >[/color]

    Comment

    Working...