0

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.

2
Contributors
3
Replies
5
Views
6 Years
Discussion Span
Last Post by go_4_tli
0

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

0

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

0

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!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.