【发布时间】:2011-08-02 20:23:42
【问题描述】:
我想在我的网站中制作一个自定义控件(注意:不是网络应用程序)
下面是代码
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
{
}
}
默认.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>
当我编译站点时,它给了我组装错误。
Error = "名称空间“AnkitControls”中不存在类型或名称空间名称“AnkitControls”(您是否缺少程序集引用?)"
【问题讨论】:
-
您的 web.config 中是否引用了
AnkitControls? -
CustomTreeViewControl.cs文件是放在本站App_Code文件夹还是其他项目中?
-
它在网站的 CustomControls 文件夹中,而不是在 App_Code 中
标签: c# asp.net .net-4.0 custom-controls