当前上下文中不存在控件? ! ! [英] A control does not exist in the current context ? ! !

查看:254
本文介绍了当前上下文中不存在控件? ! !的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello All



我从页面后面的代码中删除了命名空间



这个名字我已删除的空间显示在此截屏



然后页面后面的代码变成这样: screenshoot





,我的页面内部使用过的控件出现问题并显示错误:控件在当前上下文中不存在。



代码来源页面就像在这个链接:屏幕截图



如何解决这个问题,因为我不想使用命名空间,因为我正在关注视频教程并且他们没有使用它。



我是什么尝试过:



我是初学者,不知道该怎么办

Hello All

after i removed the namespace from the code behind the page

the name space which i have removed is shown in this screenshoot

then the code behind the page became like this : screenshoot


, i got issue with used controls inside my page and showing the error : the control is not exist in the current context.

the code source of the page is like in this link : screen shoot

how to solve this as i dont want to use the namespace because im following a video tutorial and they are not using it.

What I have tried:

im beginner and didnt know what to do

推荐答案

最好的要做的事情是离开这个项目,重新开始。 Visual Studio自动生成的代码是有原因的。您仍然可以关注视频,只需保留命名空间即可。如果您注意到 webform2 的定义被声明为

The best thing to do is throw this project away and start again. The code that is auto-generated by Visual Studio is there for a reason. You can still follow the video, just leave the namespace as it is. If you notice the definition of your webform2 is declared as
public partial class webform2 : System.Web.UI.Page



关键点是单词 partial ,表示类定义的某些部分存在于另一个文件中,该文件仍然具有名称空间宣言。除非你真的理解所有部分是如何组合在一起的,否则最好不要尝试改变它。


The key point being the word partial which indicates that some part of the class definition exists in another file, which will still have the namespace declaration. Unless you really understand how all the pieces fit together it is best not to try changing it.


这篇关于当前上下文中不存在控件? ! !的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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