网络用户控件 [英] web userControl
问题描述
我已创建在c#Asp.net 4.0一个新的空的Web应用程序,然后添加 APP_ code
文件夹,然后加3班到该文件夹。我添加了一个网络的用户控制和设置 APP_ code
类到控制参考,但它抛出一个错误。
I have create a new empty web application in c# Asp.net 4.0 and then added App_Code
folder then added 3 classes into that folder. I have added a web user control and set the reference of App_Code
class into the control but it throws an error.
类型或命名空间名称'APP_ code'中不存在的命名空间(是否缺少程序集引用?)
The type or namespace name 'App_Code' does not exist in the namespace (are you missing an assembly reference?)
任何想法?
推荐答案
这一点可能会造成混淆。
This point can be confusing.
一个 Web应用程序项目不期待 APP_ code
文件夹中。
A "web application project" is not expecting the App_Code
folder.
一个网站项目可以预料,文件夹,并知道如何使用它。
A "website project" would expect that folder and know how to use it.
不管你意识到这不是(取决于您使用的Visual Studio版本),你会得到一个WAP或当您第一次创建Web解决方案WSP。它们是不同的。这需要一些努力来从一个转换到另一个。
Whether you realize it or not (and depending upon which version of Visual Studio you use), you will get a WAP or a WSP when you first create your web solution. They are different. It takes some effort to convert from one to the other.
这里是< A HREF =HTTP://www.$c$crsbarn.com/post/2008/06/aspnet-web-site-versus-web-application-project.aspx相对=nofollow>几 解释差异的文章。
Here are a few articles explaining the differences.
要解决你眼前的问题,那么,你可以移动3类文件了 APP_ code
文件夹到根文件夹,或更好,创建一个新的文件夹包含这些类和它们移动到它。根据您是否会在该文件夹命名空间中的类,您可能需要一个引用添加到您的命名空间的用户控件
。
To solve your immediate problem, then, you can just move the 3 class files out of the App_Code
folder into the root folder, or better, create a new folder to contain those classes and move them into it. Depending upon whether you give the classes in that folder namespaces, you may have to add a reference to that namespace in your UserControl
.
这篇关于网络用户控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!