how to pass value to my user control

P

pei_world

I have a user control:

- using LoadControl("MyCtrl.ascx")
MyCtrl _mycontrol = (MyCtrl)LoadControl("MyCtrl.ascx")
Page.Controls.Add(_mycontrol);
_mycontrol.Text

it will be loaded when some events fired.
so how can I pass value to this user control from aspx template file.
 
J

John Saunders

pei_world said:
I have a user control:

- using LoadControl("MyCtrl.ascx")
MyCtrl _mycontrol = (MyCtrl)LoadControl("MyCtrl.ascx")
Page.Controls.Add(_mycontrol);
_mycontrol.Text

it will be loaded when some events fired.
so how can I pass value to this user control from aspx template file.

If your control has properties, then you can set them. If it doesn't have
properties, then you should add some and set them.

John Saunders
 
P

pei_world

Have add a property to my control. but it is not accessable from my aspx
file
 
J

John Saunders

pei_world said:
Have add a property to my control. but it is not accessable from my aspx
file

Why not? Is it a public property? You should be able to access
_mycontrol.MyProperty.

John Saunders
 

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,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top