I'm having trouble adding multiple new divs I create in the code-behind of my aspx file. I am getting the error "Cannot get inner content of because the contents are not literal"
I have tried adding the created item as a div, asp:Panel, asp:Literal, changing the parent item from div to asp:Panel.
protected void Page_Load(object sender, EventArgs e)
{
var newDiv = new System.Web.UI.HtmlControls.HtmlGenericControl();
newDiv.Style.Add(System.Web.UI.HtmlTextWriterStyle.BorderStyle,"Solid");
newDiv.Style.Add(System.Web.UI.HtmlTextWriterStyle.BorderColor,"Gray");
newDiv.Style.Add(System.Web.UI.HtmlTextWriterStyle.BorderWidth, "5px");
newDiv.Style.Add(System.Web.UI.HtmlTextWriterStyle.Width, "300px");
newDiv.Style.Add(System.Web.UI.HtmlTextWriterStyle.Height,"200px");
newDiv.Style.Add(System.Web.UI.HtmlTextWriterStyle.BackgroundColor, "White");
newDiv.Style.Add(System.Web.UI.HtmlTextWriterStyle.Cursor, "Pointer");
newDiv.Style.Add(System.Web.UI.HtmlTextWriterStyle.Display, "Inline-Block");
newDiv.Attributes.Add("runat", "server");
int i = 0;
while(i < 10)
{
parentDiv.Controls.Add(newDiv);
i++;
}
}
I keep getting "Cannot get inner content of because the contents are not literal"
Any help would be appreciated!