Can values or parameters be passed into user control? Can values or parameters be passed into user control? asp.net asp.net

Can values or parameters be passed into user control?


Yes:

<my:Control runat="server" MyPublicProperty="Value1" MyPublicProperty2="Value2"/>

Any public property can be set in the markup as indicated above. You can get more advanced than this and support child elements, etc. too. See more information.


Create public properties in the code behind of the user control and then these could be used as attributes while declaring the user control in the page. Check here