This error occurs when any control ID is missing or more than one control have the same ID assigned. to get rid of this error, make the ID values of each control unique.
see the example below, the loop increment value j is appended dynamically to the id value to make the id value increment
pnl.ID = "pnltype" + j.ToString();
for (int j = 0; j < dtRtype.Rows.Count; j++)
{
pnl = new Panel();
pnl.Width = panelWidth;
pnl.Height = panelHeight;
pnl.BackColor = Color.BlueViolet;
pnl.BorderStyle = BorderStyle.Solid;
pnl.BorderColor = System.Drawing.Color.White;
pnl.BorderWidth = 2;
pnl.Style["position"] = "absolute";
pnl.Style["bottom"] = bottom.ToString() + "px";
pnl.Style["left"] = left.ToString() + "px";
pnl.ID = "pnltype" + j.ToString();
}