ASP.. NET服务器控件显示脱离上下文的消息
本文关键字:上下文 消息 NET 服务器控件 显示 ASP | 更新日期: 2023-09-27 18:01:46
我正在使用这个简单的网页,碰巧放了一些's来纠正我的页面的样式,突然当回到。cs文件编程时,事情很奇怪。所有的代码都显示了类似的错误消息:
错误2名称"TextBox1"在当前上下文中不存在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>
右键单击aspx文件,然后选择"convert to web application", designer.cs文件就生成了