我(在VB.NET代码后面)在ASP.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”不是“System.Web.UI.UserControl成员”。
而在designer.vb页我看到:
Protected WithEvents mycontrol1 As Global.System.Web.UI.UserControl
我如何确保它成为:
Protected WithEvents mycontrol1 As Global.Mynamespace.Controls.MyControl
?
我不确定在另一个项目中引用*用户控件*(而不是常规服务器控件)是受支持的方案。 –