我(在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
?
我不確定在另一個項目中引用*用戶控件*(而不是常規服務器控件)是受支持的方案。 –