hi i have a WebUserControl that have a lable for show message how can i send a value to the lable from Page to my WebUserControl at runtime.
passing a value to WebUserControl for show in a lable
915 Views Asked by Ali At
3
There are 3 best solutions below
0

In the code behind file of your control you can specify an attribute
[Bindable(true)]
[Category("Appearance")]
[DefaultValue("")]
[Localizable(true)]
public String customType
{
get
{
String s = (String)ViewState["customType"];
return ((s == null) ? String.Empty : s);
}
set
{
ViewState["customType"] = value;
}
}
And after you can get this attribute to fill your label in the pageload with
mylabel.text = mycontrol.customType
In the asp page you specify the attribute (here is the 'customType'):
<wuc:ContSign customType="person" ID="ContSignPanel" runat="server" />
You can create a public method in your user control such as
Label1 being the label control in user control. Now you can use the method from Page as and when you need it - for example,
where MyUserControl1 is the name/ID of web user control put on the page.