Need help from designer experts: templated control

A

AW

Hello guys, it's my turn to ask for help,

I'm fighting with Visual Studio.net 2003. I made a templated control and it
displays alright when I ask the page through my browser, but Visual Studio
can't display it. It displays the usual grey rectangle with an exclamation
mark saying " '' could not be set on property 'Columns'. "

I suspect that I missed a property, but can't manage to see which one. If
anybody could help me, that would be great.

Here is the simplified code for reference.

ASPX page that uses the control:
<%@ Register TagPrefix="cc1" Namespace="Controls" Assembly="Controls" %>
....
<cc1:MyControl id="MyControl12" runat="server">
<Columns>
<cc1:Column Name="Toto" Type="A" />
<cc1:Column Name="Titi" Type="B" />
</Columns>
</cc1:MyControl>

Control and its classes:
public class MyControl : WebControl
{
private ColumnCollection m_columns ;

public MyControl()
{
m_columns = new ColumnCollection() ;
}

[PersistenceMode(PersistenceMode.InnerProperty)]
public ColumnCollection Columns
{
get { return m_columns ; }
set { m_columns = value ; }
}

protected override void Render(HtmlTextWriter writer)
{
writer.Write("<b>Hello, the columns are:<b>");
writer.Write("<ul>");
foreach(Column c in Columns)
{
writer.Write("<li>");
writer.Write(c.Name);
}
writer.Write("</ul>");
}

}

public class ColumnCollection : CollectionBase, IList, ICollection
{
public ColumnCollection() : base( )
{

}

public void Add(Column _col)
{
List.Add(_col);
}

[NotifyParentProperty(true)]
public Column this[int index]
{
get { return List[index] as Column ; }
set { List[index] = value ; }
}

}
public class Column
{
private string m_name ;
private string m_type ;

[Category("Data"),
PersistenceMode(PersistenceMode.Attribute)]
public string Name
{
get { return m_name ; }
set { m_name = value ; }
}

[Category("Data"),
PersistenceMode(PersistenceMode.Attribute)]
public string Type
{
set { m_type = value ; }
get { return m_type ; }
}

public override string ToString()
{
return m_name + "/" + m_type;
}

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top