问题
I have a UserControl named BreadCrumb. I would like to pass in information to this user control like so (Similar to DropDownList items):
<uc:BreadCrumb runat="server" id="HeaderBreadCrumb">
<AddLevel Name="Home" Url="~/Default.aspx" />
<AddLevel Name="About Us" Url="~/AboutUs.aspx" />
</uc:BreadCrumb>
Thanks to any help!
回答1:
Please take a look here How to: Create an ASP.NET User Control and here Implementing Custom UserControl with ListItem collection. These approaches doesn't uses templates.
回答2:
You can support templates, but that's not exactly what you are after.
Take a look at this Scott Guthrie page for more information on using templates on user controls.
Also, take a look at this MSDN page on how to create templated user controls.
来源:https://stackoverflow.com/questions/1971498/passing-in-content-to-asp-net-user-control