我在ASP.NET中有一个自定义控件(VB.NET代码),用ASCX定义:
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="MyControl.ascx.vb" Inherits="Mynamespace.Controls.MyControl" %> <!-- some html and other custom controls-->
并在代码背后:
Namespace Controls Public Class MyControl Inherits System.Web.UI.UserControl
这是在图书馆中设置的.不同的项目在页面中使用该控件:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="mypage.aspx.vb" Inherits="myproject.mypage" culture="auto" Meta:resourcekey="Page" uiculture="auto" Transaction="RequiresNew" MasterPageFile="Mynamespace.Master" Theme="ThemeBase2" StylesheetTheme="ThemeBase2" %> <%@ Register tagprefix="Controls" tagname="MyControl" src="../Controls/MyControl.ascx" %> <%-- some asp.net --%> <Controls:MyControl ID="mycontrol1" runat="server" MyCustomProperty="value" />
但是,当我建立,我得到一个错误说
‘MyCustomProperty’ is not a member of ‘System.Web.UI.UserControl’.
而在designer.vb页面中我看到:
Protected WithEvents mycontrol1 As Global.System.Web.UI.UserControl
如何确保它成为:
Protected WithEvents mycontrol1 As Global.Mynamespace.Controls.MyControl
?