我希望能够从自定义的ASP.NET用户控件中暴露一个复杂属性,以便可以从aspx页面中的控件标签中设置它。类似于这样:
public class TestData {
public int X;
public int Y;
}
public partial class TestControl : System.Web.UI.UserControl {
public TestData TestProperty {
get {
return ViewState["TestProperty"] as TestData;
}
set {
ViewState["TestProperty"] = value;
}
}
}
然后在包含控件的页面的 .aspx 文件中,我想要像这样的东西:
<div>
<testns:TestControl runat="server" ID="TestControl1" TestProperty="X:1,Y:2"/>
</div>