Note that there are some explanatory texts on larger screens.

plurals
  1. POCode-behind page cannot "see" any items/controls declared in the aspx page
    primarykey
    data
    text
    <p>Here's a my Default.aspx page (with unnecessary details excised):</p> <pre><code> &lt;asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"&gt; &lt;div id="login"&gt; &lt;!-- a bunch of markup has been removed, so this html will appear wrong and not valid, but it actually is --&gt; &lt;table align="center" width="80%" cellpadding="0" cellspacing="0" class="loginBg"&gt; &lt;tr&gt; &lt;td colspan="2"&gt;&lt;img src="images/Login_top.jpg" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;asp:Panel runat="server" ID="pnlLoginIn"&gt; &lt;tr&gt; &lt;td style="padding-left:20px;"&gt;Username&lt;/td&gt; &lt;td style="padding-right:15px;" align="right"&gt;&lt;asp:TextBox id="txtUsername" runat="server" /&gt;&lt;/td&gt; &lt;asp:RequiredFieldValidator runat="server" ID="rfvUserName" ErrorMessage="*" ControlToValidate="txtUsername" ValidationGroup="credentials" Display="Dynamic" /&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td style="padding-left:20px;"&gt;Password&lt;/td&gt; &lt;td style="padding-right:15px;" align="right"&gt;&lt;asp:TextBox ID="txtPassword" TextMode="Password" runat="server" /&gt;&lt;/td&gt; &lt;asp:RequiredFieldValidator runat="server" ID="rfvPassword" ErrorMessage="*" ControlToValidate="txtPassword" ValidationGroup="credentials" Display="Dynamic" /&gt; &lt;/tr&gt; &lt;!-- BUT THE PANEL IS HERE?! --&gt; &lt;asp:Panel ID="pnlInvalidCredentials" runat="server"&gt; &lt;tr&gt; &lt;td colspan="2" align="center" style="color: Red;"&gt;&lt;asp:Literal runat="server" ID="litInvalidCredentials" Text="Invalid Username or Password" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/asp:Panel&gt; &lt;!-- more code has been removed down here...I just left the block commented in where the pnlInvalidCredential lives --&gt; &lt;/asp:Content&gt; </code></pre> <p>Here's the code-behind (with unnecessary details excised):</p> <pre><code>namespace webapp { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { (webapp.MasterPages.MasterPage)Page.Master).headerImage = "default"; this.Master.headerImage = "default"; if (!Page.IsPostBack) { this.pnlInvalidCredentials.Visible = false; // error is here this.BindPressRoomItem(); } } } } </code></pre> <p>This page/code-behind is top level, it's not it any folder or anything. Also this project is an ASP.NET Web Application that is borrowing code from a legacy web <em>site</em> project. I didn't "Add Existing" to any files, all files were "Add New" to prevent compatibility problems. Tried <a href="https://stackoverflow.com/questions/1316757/cant-access-control-id-in-code-behind">this</a>, didn't work.</p> <p>In the code-behind, every attempt to manipulate items declared in the aspx page results in an error like:</p> <blockquote> <p>'_Default' does not contain a definition for 'pnlInvalidCredentials'</p> </blockquote> <p>or</p> <blockquote> <p>The name 'txtUsername' does not exist in this context.</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload