Search code examples
asp.netvb.netuser-controlsvisual-studio-2005ascx

Adding "Attributes" to UserControl


I am looking to add attributes to my UserControl when I create it on my ASP.Net page. How would I do this and how would I then access them in the code-behind of my .ascx?

In web.config: <add tagPrefix="uc" src="~/usercontrols/uc-EmailForm.ascx" tagName="EmailForm"/>

On page: <uc:EmailForm ID="EmailForm" runat="server" />

On Page Goal: <uc:EmailForm ID="EmailForm" runat="server" ShowTo="False" />

Code-Behind Goal: pnlToAddress.Visible = ShowTo


Solution

  • You have to create public property in your user control's class (in ascx.cs):

    public bool ShowTo { get; set; }