修复“名称在当前上下文中不存在”的问题Web Developer Express 中的错误
中不存在
<asp:Label ID="lblorder" runat="server" Text="Ordernumber: "></asp:Label>
名称 lblorder 在当前上下文标签代码
string test = lblorder.Text;
我讨厌这个错误。 偶尔它会弹出,我知道它与删除 aspx.designer.cs 和重建页面或解决方案文件有关,但我在 Visual Web Developer 2008 Express Edition 中工作,并且没有这个 aspx.designer .cs 文件
..帮助我..
The name lblorder does not exist in the current context label
<asp:Label ID="lblorder" runat="server" Text="Ordernumber: "></asp:Label>
code behind
string test = lblorder.Text;
I hate this error.
Once in a while it just pops up and I know that it has something to do with deleting the aspx.designer.cs and rebuilding the page or solution file but I work in Visual Web Developer 2008 Express Edition and I dont have this aspx.designer.cs file
..help me..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您始终可以打开 Visual Studio 解决方案并添加文件的 xml。
You could always open the visual studio solution and add the xml for the file.
删除 aspx.designer.cs 后,您应该能够右键单击 .aspx 文件并单击“转换为 Web 应用程序”。这将重新生成 aspx.designer.cs 文件。
Once you delete the aspx.designer.cs you should be able to right click on the .aspx file and click "Convert to Web Application". This will regenerate you aspx.designer.cs file.
我创建了网站解决方案的网络应用程序,所以现在我有 aspx.designer.cs 文件,可以清理解决方案并将其转换为网络应用程序,但错误仍然存在..
所以我刚刚在设计器文件中添加了缺少的行,现在它可以工作了;受保护的全局::System.Web.UI.WebControls.Label lblorder;
但这并不是一个永久的解决方案;每次构建后都会删除更改......
然后她发现当标签等放置在嵌套重复器中时,您必须使用findcontrol
I created a webapplication of the website solution , so now I have aspx.designer.cs files and can clean the solution and convert it to a webapplication, but the error still exists ..
So I just added the missing line in the designer file, now it works ; protected global::System.Web.UI.WebControls.Label lblorder;
but this is not a perminent solution; the changes are deleted after every built ....
and then she found it that you have to use a findcontrol when labels etc are placed in a nested repeater
我也有同样的问题,但我通过在 aspx 文件(html 文件)中提供指令来修复它。
上面的格式和内容可以通过创建一个新的 Web 应用程序项目并复制由 Visual Studio 自动生成的上述类似指令来获得!!
I too had the same problem but I fixed it by providing the directive in the aspx file (html file)
The above format and content can be obtained by making a new web application project and copything the above similar directive that is automatically generated by visual studio!!