passing parameters to static user control

  • Thread starter Thread starter Tarscher
  • Start date Start date
T

Tarscher

Hi all,

I designed a user control that I need to use in several pages. The
user control is added statically.

how can I pass parameters from the parent page to the user control?

Thanks in advance
Stijn
 
Howdy,

Expose public properties from the user control i.e.:

.... user control code - let's assume your control contains a label that
holds number customer phone number ...

public string CustomerPhone
{
get
{
return labPhone.Text;
}
set
{
labPhone.Text = value;
}
}
.... ..

Now, you can use this property programmatically (code behind):

customerData.CustomerPhone = "+44 123456789";

as well as declaratively (aspx code):

<uc1:YourCustomControlName runat="server" ID="customerData"
CustomerPhone="+44 123456789"/>
 
Back
Top