我在web.config文件中引用了多个用户控件,因为我在各个页面中收到错误,并且它们在多个页面中使用,我编写的代码如下:
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add tagPrefix="IPAMControl" tagName="confirm_list" src="~/Controls/confirmed_participant_list.ascx"/>
<add tagPrefix="IPAMControl" tagName="contact_us" src="~/Controls/contact_us.ascx" />
<add tagPrefix="IPAMControl" tagName="erh_list" src="~/Controls/erh_list.ascx" />
<add tagPrefix="IPAMControl" tagName="graphic_with_thumbnail" src="~/Controls/graphic_with_thumbnail.ascx" />
<add tagPrefix="IPAMControl" tagName="header" src="~/Controls/header.ascx" />
<add tagPrefix="IPAMControl" tagName="footer" src="~/Controls/footer.ascx" />
<add tagPrefix="IPAMControl" tagName="main_tnavbar" src="~/Controls/main_tnavbar.ascx" />
<add tagPrefix="IPAMControl" tagName="program_header" src="~/Controls/program_header.ascx" />
<add tagPrefix="IPAMControl" tagName="program_list" src="~/Controls/program_list.ascx" />
<add tagPrefix="IPAMControl" tagName="signup_section" src="~/Controls/signup_section.ascx" />
<add tagPrefix="IPAMControl" tagName="speaker_list" src="~/Controls/speaker_list.ascx" />
<add tagPrefix="IPAMControl" tagName="track" src="~/Controls/track.ascx" />
</controls>
</pages>
然而,当我进入HTML标记文件(aspx)并且键入“<IPAM...
”时,没有任何内容出现,我收到“无法识别的命名空间'IPAMControls'的错误。
下面是我尝试将其中一个控件插入的示例页面:
<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/MasterNew.master" CodeFile="~/programs/programs.aspx.cs" Inherits="IPAM.Website.programs.programs" %>
<asp:Content ID="MainContent" ContentPlaceHolderID="Main" Runat="Server">
<h1>Upcoming Programs</h1>
<hr size="1">
<p align="center"><a href="#long" class="bodylink">Long Programs</a> | <a href="#workshops" class="bodylink">Workshops</a> | <a href="#affiliate" class="bodylink">Affiliates' & Other Workshops</a> | <a href="#summer" class="bodylink">Summer Programs & Special Events</a>
</p>
Our upcoming programs include long programs, short programs (workshops), reunion conferences, and summer programs. Click on the program title for detailed information.
<%--<a name="long"><ipam:program_list id="idProgramList1" Type="Long" Time="Upcoming" runat="server" /></a>
<a name="workshops"><ipam:program_list id="idProgramList2" Type="Short" Time="Upcoming" runat="server" /></a>
<a name="affiliate"><ipam:program_list id="idProgramList3" Type="Affiliate" Time="Upcoming" runat="server" /></a>
<a name="summer"><ipam:program_list id="idProgramList5" Type="Summer" Time="Upcoming" runat="server" /></a>
<a name="special"><ipam:program_list ID="idProgramList6" Type="Special" Time="Upcoming" runat="server" /></a>--%>
</asp:Content>
我做错了什么或错过了什么。
答案 0 :(得分:1)
您可以使用以下用户控件:
<IPAMControl:confirm_list ID="<id>" runat="server"></IPAMControl:confirm_list>
我使用的是VS2008,它也没有出现在我的intellisense中。
[编辑]
<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master"
AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="accesscontrol_test" %>
<%@ Register TagPrefix="IPAMControl" TagName="confirm_list" Src="Copy of nav.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="NEContent" Runat="Server">
<h1>Upcoming Programs</h1>
<hr size="1">
<p align="center"><a href="#long" >Long Programs</a></p>
Our upcoming programs include long programs, short programs (workshops), reunion
conferences, and summer programs. Click on the program title for detailed information.
<a name="long"><IPAMControl:confirm_list id="idconfirm_list" runat="server">
</IPAMControl:confirm_list></a>
</asp:Content>
上面的代码对我来说很好,尝试像我一样在页面顶部注册它,然后我们可以帮助查明造成问题的原因。您显然必须更改指令,但是在页面中注册它而不是Web配置。
[编辑]
尝试将其添加到<pages><controls>
<add tagPrefix="IMAPControl" namespace="IMAP.Webmaster.Controls" assembly="IMAP.Webmaster" />