开发者

Can values or parameters be passed into user control?

开发者 https://www.devze.com 2023-02-15 18:07 出处:网络
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 it using something like

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 it using something like

<uc1:SampleUserControl id="SampleUserControl1" runat="server"></uc1:SampleUserContro开发者_如何学Cl>

style syntax. Can you pass parameters in there?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消