Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 单击按钮时使用JQuery ajax将数据保存到DB_C#_Jquery_Webmethod - Fatal编程技术网

C# 单击按钮时使用JQuery ajax将数据保存到DB

C# 单击按钮时使用JQuery ajax将数据保存到DB,c#,jquery,webmethod,C#,Jquery,Webmethod,以下是我的Jquery ajax方法: $(document).ready(function () { $("input[id$='btnBulten']").click(function () { //alert("dd"); $.ajax({ type: "POST", url: "http://URL/Controls/EBulten.ascx/EBultenSend", c

以下是我的Jquery ajax方法:

 $(document).ready(function () {

    $("input[id$='btnBulten']").click(function () {
        //alert("dd");
        $.ajax({
            type: "POST",
            url: "http://URL/Controls/EBulten.ascx/EBultenSend",
            contentType: "application/json; charset=utf-8",
            data: "{nameSurname:" + $("input['id$='$txtNameSurname']").val() + " }",
            dataType: "json",
            success: function (msg) {
                alert("Mesajınız başarıyla iletildi");
            }
        });
    });
});
在代码隐藏代码中:

 [WebMethod()]
public static void EBultenSend(string nameSurname, string email, string IP, string position, string firmName)
{
    int bultenId = EBulten.InsertEbulten(nameSurname, email, IP, position, firmName);
}
调用SP将数据保存到数据库的插入程序。所有参数都来自文本框。我无法将数据保存到数据库。如何修复此问题?
通常,在没有WebMethod的情况下,如果我在客户端单击时使用此方法,它会将数据插入数据库。

您确定问题出在服务器端吗?你从客户那里得到数据了吗?您是否收到任何错误消息?@user707727在我编辑时,我可以在不使用WebMethod的情况下将数据插入数据库,但要求已更改,因此我需要使用它。您是否尝试调试以查看是否调用了WebMethod?你是如何注释你的webmethod类的?我发现ascx控件不可能使用,因为它不代表URL。所以我将它改为aspx。