I'm trying to put a dynamically-generated stackpanel into my ASP.NET webpage. (I must admit, I'm pretty new at this.) Here's my ASPX page in its entirety:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Loader.aspx.cs" Inherits="eFormsIndex.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div style="vertical-align:middle">
        <asp:Panel ID="loaderPanel" runat="server">
        </asp:Panel>
    </div>
    </form>
</body>
</html>

... and here's enough of the C# to give you an idea what I'm doing:

for (int i = 0; i < headerText.GetLength(0); i++)
{
    Label newLabel = new Label();

    newLabel.Text = headerText[i];
    newLabel.ForeColor = System.Drawing.Color.DarkRed;
    newLabel.Font.Bold = true;
    docsTableHeaderCells[i].Controls.Add(newLabel);
    docsTableHeader.Controls.Add(docsTableHeaderCells[i]);
}
docsTable.Controls.Add(docsTableHeader);
loaderPanel.Controls.Add(docsTable);

Unfortunately, I get an error in the Error List:

The name 'loaderPanel' does not exist in the current context

Any idea why that might be? The code looks simple enough to be idiot-proof, but obviously, I'm doing something strange. Thanks in advance for your time.

i think you can add string value (like "<a href="ddd" class='ddd'></a>") in division not whole control

Thank you for replying, but removing the <div> tags didn't make the error go away.

I found it! I needed to change the value of "Inherits" in the ASPX file to reflect the name of the partial class that represented the page. Thanks to anyone who read this and wanted to help!