Hi.
I have created a custom web server control in asp.net. And I am trying to render a List of a class in the RenderContents method.
Here is my code:
[DefaultProperty("Items")]
[ToolboxData("<{0}:News runat=server></{0}:News>")]
public class News : WebControl
{
[Bindable(true)]
[Category("Appearance")]
[DefaultValue("")]
[Localizable(true)]
public List<NewsItem> Items
{
get
{
List<NewsItem> items = (List<NewsItem>)(ViewState["Items"] == null ? new List<NewsItem>(): ViewState["Items"]);
return items;
}
set
{
ViewState["Items"] = value;
}
}
protected override void RenderContents(HtmlTextWriter output)
{
foreach (var item in Items)
item.RenderControl(output);
}
}
First of all, when I drag drop this control onto a page, I can access the Items property from the property window in desi ...
Go to the complete details ...