我在一个网站上有一个用户控件,里面有这个。
Namespace MenuTreePanel
Public Class MenuTreePanel
Inherits System.Web.UI.UserControl
Public root As New MenuNode(0, 0, "root", "")
Public WithEvents Spany1 As HtmlGenericControl = New HtmlGenericControl("UL")
Public WithEvents Spany2 As HtmlGenericControl = New HtmlGenericControl("UL")
Public WithEvents Spany3 As HtmlGenericControl = New HtmlGenericControl("UL")
Public Function getRoot() As MenuNode
Return root
End Function
End Class
End Namespace
当我去访问 getRoot 函数时,我得到了错误
'getRoot' is not a member of 'ASP.MenuTreePanel'.
命名空间被错误地标记为 ASP,我想知道它可能来自哪里。在对象资源管理器中,我的控件列在正确的命名空间和 ASP 命名空间下。
在页面上引用使用
<%@ Register TagPrefix="MenuTreePanel" Src="~/MenuTreePanel.ascx" TagName="MenuTree" %>
<MenuTreePanel:MenuTree ID="menuTreeSelect" runat="server"></MenuTreePanel:MenuTree>
编辑2:
<%@ Control Language="vb" CodeBehind="~/MenuTreePanel.ascx.vb"className="MenuTreePanel" %>
并尝试访问它 Dim root As New MenuNode(0, 0, "root", "")
root = (menuTreeSelect).getRoot()