gpt4 book ai didi

javascript - Ajax.Utility.RegisterTypeForAjax 未注册 ajax 类型

转载 作者:行者123 更新时间:2023-11-27 23:23:23 25 4
gpt4 key购买 nike

当我使用 Ajax.Utility.RegisterTypeForAjax 时,出现错误。错误消息说:处理回调函数时出错。自动刷新终止。错误:“MyAjaxClass”未定义。我的代码如下所示:

public class MyAjaxClass
{
Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.ReadWrite
public string SaveData (int count)
{
return something;
}

}
public partial class webaccess: Page
{
protected void Page_Load(object sender, EventArgs e)
{
Ajax.Utility.RegisterTypeForAjax(typeof(MyAjaxClass));
}
}

I added below config handlers in web.config.
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated" />
<add verb="POST,GET" name="Ajax" path="ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax" />
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" 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" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="ScriptResource" 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>

请让我知道我还能做什么。

最佳答案

代码中的语法错误

 Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.ReadWrite

替换为

  [Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.ReadWrite)]

关于javascript - Ajax.Utility.RegisterTypeForAjax 未注册 ajax 类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35198520/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com