how to pass value to my user control

  • Thread starter Thread starter pei_world
  • Start date Start date
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.
 
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
 
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

Back
Top