How to set custom object property on ASP.NET WebControl through markup

kgtmaster

New Member
I am struggling how to set a custom property which is suppose to point to an instance of my custom class on an ASP.NET webcontrol.Sample web control:\[code\]public class CustomControl : System.Web.UI.WebControls.Panel{ public IFactory Factory { get; set; }}\[/code\]Code behind:\[code\]public partial class Main : System.Web.UI.Page{ public IFactory GetFactory { get { return new CustomFactory(); } }}public class CustomFactory : IFactory {}\[/code\]The custom factory get initialized on the code behind. In my markup (not in code behind), I need to set the Factory property on my CustomControl to the instance in my code behind. Any variation of inline code that I tried did not work:\[code\]<asp:CustomControl ID="MyCustomControl" Factory="<%GetFactory%>" runat="server" /><asp:CustomControl ID="MyCustomControl" Factory="<%=GetFactory%>" runat="server" />\[/code\]Can anyone assist how to do this?
 
Back
Top