我刚刚为用户控件项目添加了一个新的UserControl。我只使用默认生成的代码而不进行任何编辑。当我尝试将UserControl放在单独项目的测试页面上时,intellisense会显示我的程序集中的所有用户控件,除了我刚添加的控件。如果我输入用户控件的名称,则表示它不是已知元素。我已尝试在所有不同的订单中重新启动VS,清理和重建。如何让VS识别用户控件?
ASCX:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControl1.ascx.cs" Inherits="CustomControls2.WebUserControl1" %>
ascx.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace CustomControls2
{
public partial class WebUserControl1 : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
测试页面:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TestPage2.aspx.cs" Inherits="TestDriver.TestPage2" %>
<%@ Register Assembly="CustomControls2" Namespace="CustomControls2" TagPrefix="Test" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<Test:WebUserControl1 id="asdf" runat="server" />
</div>
</form>
</body>
</html>