2009-09-10 135 views
1

我们的Web应用程序有我们设置了一个标记,代号后面的控制,和设计师的文件,像这样:移动一个Web用户控件不同的命名空间

标记

<%@ Control Language="VB" AutoEventWireup="false" 
    Inherits="NewNameSpace.Controls.generic_selector" Codebehind="generic-selector.ascx.vb" %> 

对于一些因此,尽管它时,它是默认的命名空间工作过,当我们把它移到一个新的命名空间,我们现在得到一个解析器错误:

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not load type 'NewNameSpace.Controls.generic_selector'.

附录:我确实将标记,代码隐藏和设计器文件移动到新的名称空间。似乎没有帮助。

该项目仍然正确构建。还有什么我们需要做的吗?


更新

本周我们再看一下它,这是我的猜测。在默认情况下创建控件时,它将转到Global.NameOfProject.NameOfControl。

也许新控件现在在Global.NameOfProject.NewNameSpace.Controls?


更新:

控制确实出现了命名空间中的Global.NameOfProject.NewNameSpace.Controls部分去。问题在于,如何将整个类移动到新的名称空间并不清楚。我已经尝试过各种标记更改,并且它们都不会粘住 - 只有默认的命名空间似乎可以在没有打嗝的情况下工作。

所以我的问题仍然存在:如何将Web用户控件移动到不同的命名空间?

回答

3

您还需要更改代码隐藏类的名称空间。

打开generic-selector.ascx.vb文件,并确保该generic-selector类型被包裹在PROPERT命名空间是这样的:

Namespace NewNameSpace.Controls 
    Class generic-selector 

    End Class 
End Namspace 
+0

尽管这已经是一个很好的起点。 – Chris 2009-09-14 14:45:46

2

我哈得同样的问题,我thoug和你一样ONY我inclued我的CodeFile正常然而在阅读这个博客aspnet-context-is-not-member-of-user.html后,通过智能感知改变了我的代码文件,它工作。看起来它需要相对路径

When creating a custom user control you may encounter an error stating that "Context is not a member of ControlName". There are numerous reasons why this may appear. The most common that I have seen are:

Missing the Namespace in the Inherits property (if you are not using one than this does not apply) Missing a CodeFile or the CodeFile path is wrong, you can use the Intellisense to browse for the file to ensure proper pathing

+1

Lone链接[被认为是一个糟糕的答案](http://stackoverflow.com/faq#deletion),因为它本身毫无意义,并且目标资源不能保证在将来活着。 [这将是最好的](http://meta.stackexchange.com/q/8259)在这里包括答案的基本部分,并提供链接供参考。 – j0k 2012-11-30 12:38:14

相关问题