I am attempting to do this:Post I Have Tried Over and Over But Failed
But even after following the examples and the accepted answer I can't get my page to recognise the properties of the class in the List<>.
This is the code behind my UserControl:
namespace TEST.ctrl.forms
{
public class listItem
{
public string Name { get; set; }
}
public partial class ddl : System.Web.UI.UserControl
{
[PersistenceMode(PersistenceMode.InnerProperty)]
public List<listItem> ddlItem { get; set; }
}
}
And this is the aspx page:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="frm_Test.aspx.cs" Inherits="TEST.forms.products.frm_Test" %>
<%@ Register Src="~/ctrl/forms/ddl.ascx" TagPrefix="d" TagName="ddl" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>TEST</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<d:ddl ID="ddl1" runat="server">
<ddlItem Name="Bob"></ddlItem>
<ddlItem Name="Dave"></ddlItem>
<ddlItem Name="Frank"></ddlItem>
</d:ddl>
</div>
</form>
</body>
</html>
The page understands d:ddl and offers ddlItem as a property but doesn't know what 'Name' is. Am I missing something?