-5
 $("[id$=_btnPostReminder]").click(function(){
     var a = $find("<%=Editor1.ClientID%>");
     var remindertext = a.get_content();
     var re=$("#<%=hiddReminderTicketId.ClientID%>").text();
     var res= $("#<%=txtReminderon.ClientID%>").val();
     $.ajax({
        type: "POST",
        url: "AllTickets.aspx/btnPostReminder",
        data: '{TicketId: ' + re + ',remindertext: ' +  remindertext  + ',reminderon: ' +  res  + '}',
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success:
        function Ret(response) { 
        var Result=response.d
        alert(Result)
        $("#<%=txtReminderon.ClientID%>").val("")
        $('#<%=hiddReminderTicketId.ClientID %>').text("")
        $('#<%=lblAlert.ClientID %>').text("Set Successfully");
        return false;
        },
        error: function(data, status, jqXHR) {                        
        alert(jqXHR);
        }
    }); 
    return false;
});

后面的 C# 代码:

[System.Web.Services.WebMethod()]
public static string btnPostReminder(Int64 TicketId, string remindertext, string reminderon)
{
    Common objCommon = new Common();
    DAL objDal = new DAL();
    SqlParameter[] para = new SqlParameter[4];
    para[0] = new SqlParameter("@ticketid", DbType.Int64);
    para[0].Value = TicketId;
    para[1] = new SqlParameter("@REMINDERTEXT", DbType.String);
    para[1].Value = remindertext;
    para[2] = new SqlParameter("@REMINDERON", DbType.DateTime);
    para[2].Value = objCommon.ReturnDate(reminderon);
    para[3] = new SqlParameter("@CREATEDBY", DbType.Int64);
    para[3].Value = Convert.ToInt64(1);

    objDal.ExecuteSP("CREATE_REMINDER", para);

    return   " successfully";
}
4

1 回答 1

2

好的找到你的问题,你传递Int64的参数应该是字符串,否则当它改变到下面我得到成功消息:

 [System.Web.Services.WebMethod()]
 public static string btnPostReminder(string TicketId, string remindertext, string reminderon)
    {
        return " successfully";
    }

此外,您的数据应如下所示:

 data: '{"TicketId":"' + re + '","remindertext":"' + remindertext + '","reminderon":"' + res + '"}',

作为参数的字符串传递,并TryParse查看它是否属于int.

于 2013-06-28T14:29:17.940 回答