ASP.Net: элемент <name>не является известным элементом - PullRequest
1 голос
/ 12 августа 2009

Я пытался использовать AutoComplete Extender из ASP.NET Ajax Control Toolkit, однако у меня были тонны проблем с его работой.

Чтобы установить 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>

Ответы [ 3 ]

1 голос
/ 12 августа 2009

Я исправил это и заставил это работать. Мне пришлось внести изменения в мою страницу aspx и мой web.config.

ASPX: Добавил это в начало моей страницы:

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" tagprefix="ajaxToolkit"%>

Мой контроль теперь выглядит так:

        <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" ID="AutoComplete1" 
                                          TargetControlID="txtOrganization" 
                                          ServicePath="AutoComplete.asmx" ServiceMethod="GetOrganizationList"
                                          MinimumPrefixLength="1" EnableCaching="true"
                                          FirstRowSelected="true">
        </ajaxToolkit:AutoCompleteExtender>

Что касается моего web.config, я добавил следующее:

<configSections>
    <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
        <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
            <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
            <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
                <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere"/>
                <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
                <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
            </sectionGroup>
        </sectionGroup>
    </sectionGroup>
</configSections>

<system.web>
    <pages>
        <controls>
            <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        </controls> 
    </pages>
    <customErrors mode="Off"/>
    <compilation debug="true" strict="false" explicit="true">
        <assemblies>
            <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            <add assembly="System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
            <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        </assemblies>               
    </compilation>
    <httpHandlers>
        <remove verb="*" path="*.asmx"/>
        <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
    </httpHandlers>
    <httpModules>
        <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </httpModules>
    <sessionState mode="InProc" cookieless="false" timeout="240"/>
    <!--
        The <authentication> section enables configuration 
        of the security authentication mode used by 
        ASP.NET to identify an incoming user. 
    -->
    <authentication mode="Forms"/>
    <!--
        The <customErrors> section enables configuration 
        of what to do if/when an unhandled error occurs 
        during the execution of a request. Specifically, 
        it enables developers to configure html error pages 
        to be displayed in place of a error stack trace.

    <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
        <error statusCode="403" redirect="NoAccess.htm" />
        <error statusCode="404" redirect="FileNotFound.htm" />
    </customErrors>
    -->
    <httpRuntime maxRequestLength="16000" useFullyQualifiedRedirectUrl="true" executionTimeout="180"/>
</system.web>
<system.web.extensions>
    <scripting>
        <webServices>
            <!-- Uncomment this line to customize maxJsonLength and add a custom converter -->
            <!--
  <jsonSerialization maxJsonLength="500">
    <converters>
      <add name="ConvertMe" type="Acme.SubAcme.ConvertMeTypeConverter"/>
    </converters>
  </jsonSerialization>
  -->
            <!-- Uncomment this line to enable the authentication service. Include requireSSL="true" if appropriate. -->
            <!--
    <authenticationService enabled="true" requireSSL = "true|false"/>
  -->
            <!-- Uncomment these lines to enable the profile service. To allow profile properties to be retrieved
       and modified in ASP.NET AJAX applications, you need to add each property name to the readAccessProperties and
       writeAccessProperties attributes. -->
            <!--
  <profileService enabled="true"
                  readAccessProperties="propertyname1,propertyname2"
                  writeAccessProperties="propertyname1,propertyname2" />
  -->
        </webServices>
        <!--
  <scriptResourceHandler enableCompression="true" enableCaching="true" />
  -->
    </scripting>
</system.web.extensions>
<system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules>
        <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </modules>
    <handlers>
        <remove name="WebServiceHandlerFactory-Integrated"/>
        <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </handlers>
</system.webServer>

Первоначально, поскольку я использую asp.net 2.0, номера версий System.Web.Extensions были 1.6 .... Поэтому мне пришлось изменить все на 3.5.0.0.

Кроме того, во время поиска решения многие люди говорили, что мне нужно поместить копию файлов System.Web.Extensions.dll и System.Web.Extensions.Design.dll в папку bin. Мне не нужно было этого делать, я просто добавил ссылку на них.

0 голосов
/ 12 августа 2009

Вы разместили ScriptManager в верхней части страницы? Это необходимо для правильной работы элементов управления Toolkit.

РЕДАКТИРОВАТЬ: Есть много потенциальных причин этой проблемы; вы неправильно установили инструментарий AJAX, на вашем сайте есть ошибки компиляции и т. д. Одна из наиболее распространенных проблем заключается в том, что вам необходимо объявить инструментарий в файле web.config. Внутри тега страниц добавьте следующее:

<controls>
<add tagPrefix="ajaxToolkit" namespace="AjaxControlToolkit" assembly="AjaxControlToolkit"/>
</controls>
0 голосов
/ 12 августа 2009

Вы добавили ссылку на него для проекта? Щелкните правой кнопкой мыши проект из Visual Studio ... Хит Свойства Рядом со ссылками вы должны увидеть там AjaxControlToolkit ... Если нет, нажмите кнопку Добавить ..., перейдите на вкладку Обзор и выберите ее.

Я предполагаю, что другие элементы управления не работают?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...