androidrill
androidrill

Reputation: 99

ASP.NET Server Controls Showing Out Of Context Msg

I was working with this simple web page and happened to put some 's to correct the styling of my page and suddenly when got back to programming in the .cs file, things are strange. All the code is showing a similar error msg:

Error 2 The name 'TextBox1' does not exist in the current context d:\ADO_NETprojects\mywebsite\Default2.aspx.cs

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs"     `enter code here`Inherits="Default2" %>

  <html xmlns="http://www.w3.org/1999/xhtml">
  <head runat="server">
  <title></title>
   </head>
 <body>
 <form id="form1" runat="server">
 <div runat="server">

    <div>
    <asp:ListBox ID="ListBox1" runat="server" AutoPostBack="True" 
        onselectedindexchanged="ListBox1_SelectedIndexChanged" Width="179px"     style="margin-left:100px; margin-bottom:20px;">
    </asp:ListBox>
     </div>

     <hr/>
     <div>
     ListBoxItems 
     <asp:TextBox ID="TextBox1" runat="server"  style="margin-left:20px; margin-top:20px;"></asp:TextBox>
     </div>

     <div>
     <asp:Button ID="Button1" runat="server" onclick="Button1_Click" 
        style="height: 26px; margin-left:100px; margin-top:15px;" Text="ListsBoxItems"  />
     </div>
     <hr/>


     <div>
     DeleteItems:
     <asp:TextBox ID="TextBox2" runat="server" style="margin-top:10px; margin-     left:25px;"></asp:TextBox>
     </div>
     <hr/>

     <div>
     <asp:DropDownList ID="DropDownList1" runat="server" 
             style="margin-top:20px; margin-left:100px; width:200px;" 
            AutoPostBack="True"      onselectedindexchanged="DropDownList1_SelectedIndexChanged">
     </asp:DropDownList>
     </div>

     <div>
     DropDownList:
     <asp:TextBox ID="TextBox3" runat="server" style="margin-left:2px; margin-top:15px;" 
            AutoPostBack="True"></asp:TextBox>
     </div>
     <hr/>


    </div>
    </form>
    </body>
    </html>

Upvotes: 0

Views: 85

Answers (1)

Kumar Manish
Kumar Manish

Reputation: 3772

right-click on the aspx file, then choose "convert to web application" and then, the designer.cs file is regenerated

Upvotes: 2

Related Questions