ASP.NET服务器控件显示断章取义消息 [英] ASP.NET Server Controls Showing Out Of Context Msg

查看:93
本文介绍了ASP.NET服务器控件显示断章取义消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我被这个简单的网页工作时就回到了cs文件编程碰巧把一些的纠正我的页面风格和突然,事有蹊跷。所有code则呈现出类似的错误信息:

错误2'TextBox1中不存在于当前上下文D的存在是该名:\\ ADO_NETprojects \\ mywebsite \\ Default2.aspx.cs

 <%@页面语言=C#AutoEventWireup =真codeFILE =Default2.aspx.cs'输入code here`Inherits =默认2%GT;

 < HTML的xmlns =htt​​p://www.w3.org/1999/xhtml>
  <头=服务器>
  <标题>< /标题>
   < /头>
 <身体GT;
 <表ID =form1的=服务器>
 < D​​IV =服务器>    < D​​IV>
    < ASP:列表框ID =ListBox1的=服务器的AutoPostBack =真
        onselectedindexchanged =ListBox1_SelectedIndexChangedWIDTH =179px的风格=保证金左:100像素;保证金底:20像素;>
    < / ASP:列表框>
     < / DIV>     <小时/>
     < D​​IV>
     ListBoxItems
     < ASP:文本框ID =TextBox1的=服务器的风格=保证金左:20像素;的margin-top:20px的;>< / ASP:文本框>
     < / DIV>     < D​​IV>
     < ASP:按钮的ID =Button1的=服务器的onclick =的button1_Click
        风格=高度:26px;保证金左:100像素;的margin-top:15px的;文本=ListsBoxItems/>
     < / DIV>
     <小时/>
     < D​​IV>
     DeleteItems:
     < ASP:文本框ID =TextBox2中=服务器的风格=的margin-top:10px的; margin-左:25像素;>< / ASP:文本框>
     < / DIV>
     <小时/>     < D​​IV>
     < ASP:DropDownList的ID =DropDownList1=服务器
             风格=的margin-top:20px的;保证金左:100px的;宽度:200像素;
            的AutoPostBack =真onselectedindexchanged =DropDownList1_SelectedIndexChanged>
     < / ASP:DropDownList的>
     < / DIV>     < D​​IV>
     下拉列表:
     < ASP:文本框ID =TextBox3=服务器的风格=保证金左:2px的;的margin-top:15px的;
            的AutoPostBack =真>< / ASP:文本框>
     < / DIV>
     <小时/>
    < / DIV>
    < /表及GT;
    < /身体GT;
    < / HTML>


解决方案

在ASPX文件上单击右键,然后选择转换为Web应用程序,然后在designer.cs文件再生

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>

解决方案

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

这篇关于ASP.NET服务器控件显示断章取义消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆