Reputation:
Strange situation, one of my panels declared in ASPX file is not seen in code-behind. It causes build errors. So, there are two questions here:
1) I have an asp:Panel pnlList in ASPX file. I try to add a control to it in code-behind, but .NET underlines it with blue line and says that the panel does not exist. So, build errors occur. But when I just run a page without building application, this page works fine. See code samples:
ASPX:
<div style="position: absolute; top: 25px; left: 515px; width: 403px; height: 187px; overflow-y: scroll; overflow-x: hidden;">
<asp:Panel ID="pnlList" runat="server" Style="position: absolute; top: 0px; left: 0px; width: 400px;" EnableViewState="False">
</asp:Panel>
</div>
ASPX.CS:
pnlList.Controls.Add(pnlItem);
2) How to make Visual Studio see and highlight syntax in ASPX pages? It doesn't highlight it at all and moreover, it doesn't autocomplete my code in code-behind when I start typing a name of any object declared in ASPX page.
Upvotes: 2
Views: 944
Reputation: 2602
If you are using a web application or some how have a .designer.cs file for your aspx page, you need to make sure your panel is added to your designer file, now that in most cases is automatically generated by the visual studio, but there is no harm to type it manually in some cases.
Upvotes: 2