开发者

ASP.NET error with Assembly

Hello I am creating an ASP.NET/C# website and I want to use the Ajax Toolkit assembly. I added it to the "References".

In Default.aspx I have this:

<%@ Page Title="My_Website" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" ViewStateMode="Enabled" CodeBehind="Default.aspx.cs"
Inherits="My-Website开发者_StackOverflow社区._Default" %>

<%@ Register TagPrefix="ajaxToolkit" Namespace="AjaxControlToolkit" Assembly= "AjaxControlToolkit"%>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<ajaxToolkit:ComboBox ID="ComboBox1" runat="server" />
</asp:Content>

In the Design Tab I can see the Combo box and everything is fine. But when I try to debug the application I get this error:

Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "AjaxControlToolkit.Properties.Resources.NET4.resources" was correctly embedded or linked into assembly "AjaxControlToolkit" at compile time, or that all the satellite assemblies required are loadable and fully signed.


I had the same error message while ago and it was caused due to missing ScriptManager. Try to add ScriptManager to your aspx page.

<asp:ScriptManager runat="server"></asp:ScriptManager>

Or you can add ScriptManager dynamically at Page_Load event of code behind.

if (ScriptManager.GetCurrent(Page) == null)
{
     Page.Form.Controls.AddAt(0, new ScriptManager());
}

If you want to learn why we need ScriptManager when ASP.NET AJAX ToolKit is used you can check here.


Where did you get the Ajax toolkit assembly? Wasn't there any resource files with it (language resources etc.)? I have had this problem before when adding a reference to the assembly from a location where such resources were not present.

Upon removing, and adding from the originating location (where the resource files reside alongside) then the required files are also added to the references folder. All of these resources being added are a bit of a pain, actually (since they insist on expanding over an over!), if you're not using them, but I haven't found a way to 'turn off' this behaviour yet.

As a side note, you can place the following line within the <pages><controls> element of your web.config to enable access to the toolkit controls through the specified TagPrefix throughout your pages:

<add assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagPrefix="Ajax"/>


You may need to add the ToolkitScriptManager and not the ScriptManager

  • You must use the ToolkitScriptManager instead of the ScriptManager with the Ajax Control Toolkit.

It's written in the notes in the following link:

https://ajaxcontroltoolkit.codeplex.com/releases/view/116091


Add to form:

<asp:ScriptManager ID="ScriptManager1" runat="server" /> or <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" />


Add a Script manager with UpdatePanel. The Problem will be solved

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜