2009-08-11 21 views
1

私はASP.NET Ajax Control ToolkitのAutoComplete Extenderを使用しようとしていましたが、実際にはうまくいきませんでした。ASP.Net:要素<name>は既知の要素ではありません

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> 

答えて

1

私はそれを修正して動作させました。私は自分のaspxページと私のweb.configに変更を加えなければならなかった。

ASPX:私のコントロールは次のようになります

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

:私のページの最上部へ を追加しました。この私のweb.configファイルについては

 <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> 

、私は次のように追加しました:

<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

んでしたプロジェクトの参照を追加しますか? Visual Studio内でプロジェクトを右クリック... 参照の横にAjaxControlToolkitが表示されるはずです... そうでなければ、[参照...]タブをクリックして選択します。

他のコントロールは動作しないものとしますか?

+0

AjaxControlToolKitへの参照が以前に追加されましたが、それでもエラーメッセージが表示されます。 すべてのコントロールは、残念ながら、AJAXコントロールツールキットおよびAJAX拡張 – Anton

0

ページの上部にScriptManagerを配置しましたか? Toolkitコントロールを正しく動作させるには、これを行う必要があります。

EDIT:この問題の原因は多数あります。 AJAXツールキットを正しくインストールしていない、サイトにコンパイルエラーがあるなどの一般的な問題の1つは、web.configファイルでツールキットを宣言する必要があることです。 pagesタグの中に以下を追加してください:

<controls> 
<add tagPrefix="ajaxToolkit" namespace="AjaxControlToolkit" assembly="AjaxControlToolkit"/> 
</controls> 
+0

を除き、仕事、私はそれを追加するとき、それは私に同じエラーを与えるが、多くの掘削後のScriptManager – Anton

+0

のために、私はこの問題は、何か他のものだと思う:または 名前空間プロジェクトレベルのImports 'System.Web.Extensions.Design'で指定された型にパブリックメンバが含まれていないか、または見つかりません。名前空間または型が定義されており、少なくとも1つのパブリックメンバーが含まれていることを確認してください。インポートされた要素名にエイリアスが使用されていないことを確認します。 – Anton

関連する問題