简体   繁体   English

如何使用c#在ASP.net上的“动态数据”中添加Webmethod

[英]How to add Webmethod in “Dynamic Data” on ASP.net with c#

[WebMethod(EnableSession = true)]
public static string SaveFavourites(string id, bool check)
{
    //My Code here
}

This method is inside Dynamic Data folder(DynamicData/CustomePages/Products). 此方法位于“动态数据”文件夹(DynamicData / CustomePages / Products)中。 I just trigger ajax call to this method. 我只是触发对此方法的ajax调用。

Unfortunatly its not working. 不幸的是,它无法正常工作。 Its return me "404 Not found" 它返回我“ 404未找到”

Here my ajax CALL. 这是我的Ajax CALL。

$.ajax(
        {
            type: "POST",
            url: "List.aspx/SaveFavourites",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            async: true,
            data: { "id": productID, "chkboxValue": chkboxValue },
            success: function (result) {
                alert(result);
            }
        });

Please Help at the earliest. 请尽早提供帮助。

It seems you are putting incorrect url in jquery ajax call. 看来您在jquery ajax调用中输入了错误的url。

Is your page, where you have written jquery ajax call, is under DynamicData/CustomePages/Products? 您编写jquery ajax调用的页面是否在DynamicData / CustomePages / Products下? If yes then your url is correct otherwise you have to put correct url. 如果是,则您的网址正确,否则您必须输入正确的网址。

HINT : use relative path. 提示:使用相对路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Asp.net中调用webmethod C# - How to call webmethod in Asp.net C# WebMethod在C#ASP.NET代码中为静态的问题 - Issue with WebMethod being Static in C# ASP.NET Codebehind ASP.NET Server不会将页面重新发送到C#WebMethod上的客户端 - ASP.NET Server not resending page to client on C# WebMethod 无法在C#/ ASP.NET中调试静态Web方法 - Cannot debug static webmethod in C#/ASP.NET 如何在C#中的ASP.NET应用程序中调用Web方法? - How can I call my webmethod in my ASP.NET app in c#? 如何在C#中的ASP.NET中的动态页面中添加动态字段 - How to add Dynamic Field in Dynamic Page in ASP.NET in C# 将Ajax CalendarExtender添加到ASP.NET C#中的动态文本框 - Add Ajax CalendarExtender to a dynamic textBox in ASP.NET C# 使用C#将动态数据插入asp.net中的sql服务器 - inserting dynamic data into a sql server in asp.net with C# 我想知道如何在asp.net C#中的动态文本框中添加位置! - I would like to know how to add location to dynamic textboxes in asp.net C# ! (动态数据,ASP.Net,C#,下拉列表自定义.ascx控件)如何在下拉列表之间传递值? - (Dynamic Data, ASP.Net, C#, dropdownlists custom .ascx controls ) HOW TO PASS VALUES AMONG DROPDOWNLISTS?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM