添加自定义控制我想在我的网站自定义的控制(注意:不是Web应用程序)asp.net网站中
以下是代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace AnkitControls
{
/// <summary>
/// Summary description for CustomTreeView
/// </summary>
public class CustomTreeViewControl : WebControl
{
}
}
的Default.aspx:
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="AnkitControls" Namespace="AnkitControls" TagPrefix="CustomCtrl" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<h2>
Welcome to ASP.NET!
</h2>
<p>
To learn more about ASP.NET visit <a href="http://www.asp.net" title="ASP.NET Website">www.asp.net</a>.
</p>
<p>
You can also find <a href="http://go.microsoft.com/fwlink/?LinkID=152368&clcid=0x409"
title="MSDN ASP.NET Docs">documentation on ASP.NET at MSDN</a>.
</p>
</asp:Content>
当我编译的网站,它给我错误的程序集。
错误=“类型或命名空间名称AnkitControls'不存在命名空间存在‘AnkitControls’(是否缺少程序集引用?)”
在您的web.config中引用了'AnkitControls'吗? –
CustomTreeViewControl.cs文件是否放置在本网站的App_Code文件夹中或另一个项目中? –
这是CustomControls文件夹中的网站没有在App_Code文件 – Ankit