ASP.Net:元素<名称>不是已知元素名称>
我一直在尝试使用 ASP.NET Ajax Control Toolkit 中的 AutoComplete Extender,但是在让它实际工作时遇到了很多麻烦。
为了安装 AjaxControlToolKit,我将其放置在应用程序的 bin 目录中,然后将控件拖放到表单中。 然而,它一直说,
“元素‘AutoCompleteExtender’不是一个已知元素”
所以一开始,我以为我还没有注册它,但是当我查看标题时,它已经在那里了:
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TagPrefix="asp" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" tagprefix="ajaxToolkit"%>
所以我不确定总而言之,为什么它仍然给我带来问题。
我的 bin 文件夹中的其他程序集文件包括:
System.Web.Extensions.ddl System.Web.Extensions.Design.dll
这是我的代码:
<asp:TextBox ID="txtOrganization" runat="server" Width ="500px" MaxLength ="250"></asp:TextBox>
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="AutoComplete.asmx" />
</Services>
</asp:ScriptManager>
<ajaxToolkit:AutoCompleteExtender runat="server" TargetControlID="txtOrganization" ServiceMethod="GetOrganizationList" ServicePath="AutoComplete.asmx"></ajaxToolkit:AutoCompleteExtender>
I've been trying to use the AutoComplete Extender from the ASP.NET Ajax Control Toolkit, however I've been having tons of trouble getting it to actually work.
To install the AjaxControlToolKit, I've placed it inside my application's bin directoy, then I just dragged and dropped the control into the form. However, it keeps saying,
"Element 'AutoCompleteExtender' Is Not A Known Element"
So at first, I thought I had not registered it yet, but when I looked at the header, it was already there:
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TagPrefix="asp" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" tagprefix="ajaxToolkit"%>
So I'm not sure at all, why its still giving me problems.
Other assembly files in my bin folder include:
System.Web.Extensions.ddl
System.Web.Extensions.Design.dll
Here's my code:
<asp:TextBox ID="txtOrganization" runat="server" Width ="500px" MaxLength ="250"></asp:TextBox>
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="AutoComplete.asmx" />
</Services>
</asp:ScriptManager>
<ajaxToolkit:AutoCompleteExtender runat="server" TargetControlID="txtOrganization" ServiceMethod="GetOrganizationList" ServicePath="AutoComplete.asmx"></ajaxToolkit:AutoCompleteExtender>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我修好了它并让它工作。 我必须更改我的 aspx 页面和 web.config。
ASPX:
将其添加到我的页面顶部:
我的控件现在看起来像这样:
至于我的 web.config,我添加了以下内容:
本来,由于我使用的是asp.net 2.0,System.Web.Extensions的版本号是1.6....所以我不得不将其全部更改为3.5.0.0。
另外,在寻找解决方案时,很多人说我必须将 System.Web.Extensions.dll 和 System.Web.Extensions.Design.dll 的副本放入 bin 文件夹中。 我不必这样做,我只是添加了对它们的引用。
I fixed it and got it working. I had to make changes to my aspx page and my web.config.
ASPX:
Added this to the top of my page:
My control now looks like this:
As for my web.config, I added the following:
Originally, since I'm using asp.net 2.0, the version numbers of System.Web.Extensions was 1.6.... So I had to change it all to 3.5.0.0.
Also, while searching for a solution, alot of people said I had to put a copy of System.Web.Extensions.dll and System.Web.Extensions.Design.dll into the bin folder. I didn't have to do this, I just merely added a reference to them.
您是否为项目添加了对它的引用?
在 Visual Studio 中右键单击项目...点击“属性”
在参考资料旁边,您应该会看到 AjaxControlToolkit...
如果没有,请点击“添加...”进入“浏览”选项卡并选择它。
我假设没有其他控件起作用?
Did you add a reference to it for the project?
Right click on the project from within Visual Studio...Hit Properties
Next to references you should see the AjaxControlToolkit in there...
If not, hit Add...got to Browse tab and select it.
I assume no other controls work?
您是否在页面顶部放置了 ScriptManager? 您必须执行此操作才能使 Toolkit 控件正常工作。
编辑:导致此问题的潜在原因有很多; 您没有正确安装 AJAX 工具包、您的站点存在编译错误等。较常见的问题之一是您需要在 web.config 文件中声明该工具包。 在页面标签内,添加以下内容:
Did you place a ScriptManager at the top of the page? You have to do this to get the Toolkit controls to work properly.
EDIT: There are many potential causes of this problem; you did not install the AJAX toolkit correctly, there are compilation errors in your site, etc. One of the more common problems is that you need to declare the toolkit in your web.config file. Inside the pages tag, add the following: