Can values or parameters be passed into user control?

后端 未结 2 1393
醉梦人生
醉梦人生 2021-02-05 04:01

I haven\'t used these in awhile. I was just wondering is it possible to pass values or parameters to a user control from the aspx page. Say you register a control and then use i

相关标签:
2条回答
  • 2021-02-05 04:20

    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.

    0 讨论(0)
  • 2021-02-05 04:28

    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

    0 讨论(0)
提交回复
热议问题