webmethod

The length of the string exceeds the value set on the maxJsonLength property

余生颓废 提交于 2019-11-26 16:40:01
问题 I am loading tab content data through jQuery's ajax post method via web method with around 200-300 records. And getting following error in the console: Error: Sys.Net.WebServiceFailedException: Sys.Net.WebServiceFailedException: System.InvalidOperationException-- Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property. Changing the length of the maxJsonLength attribute in Web.config like

Call non-static method in server-side from client-side using JavsScript

主宰稳场 提交于 2019-11-26 16:28:49
How do I call a non-static method in server side(aspx.cs) from client side using javascript (aspx)....? As far as I know I can call static method in server side from client side... server side: [WebMethod] public static void method1() { } client side: <script language="JavaScript"> function keyUP() { PageMethods.method1(); } </script> <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"> </asp:ScriptManager> It works. Now how do I call non-static method from client side? You can avoid the static constraint by using a simple .asmx page instead of the codebehind page. 1

Pass a user defined object to ASP.NET Webmethod from jQuery, using JSON

十年热恋 提交于 2019-11-26 13:46:20
问题 I am trying to pass in some simple JSON to an ASP.NET 4.5 Webmethod from jQuery. And it is not working quite the way I want it. It works if I accept the inputs as separate parameters: [WebMethod] public static Address GetJSonAddress(string name, string street) But if I try to take it as an object it does not work, what gets passed in is simply null: [WebMethod] public static Address GetJSonAddress(Address newAddress) I have tried Webmethods, Pagemethods, WCF using DataContractJsonSerializer..

ASP.NET Calling WebMethod with jQuery AJAX “401 (Unauthorized)”

青春壹個敷衍的年華 提交于 2019-11-26 11:44:55
Been stuck with this for hours {"Message":"Authentication failed.","StackTrace":null,"ExceptionType":"System.InvalidOperationException"} I'm trying to call this WebMethod in my ASP.Net Webform [WebMethod] public static string GetClients(string searchTerm, int pageIndex) { string query = "[GetClients_Pager]"; SqlCommand cmd = new SqlCommand(query); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@SearchTerm", searchTerm); cmd.Parameters.AddWithValue("@PageIndex", pageIndex); cmd.Parameters.AddWithValue("@PageSize", PageSize); cmd.Parameters.Add("@RecordCount",

Calling a &#39;WebMethod&#39; with jQuery in ASP.NET WebForms

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 11:23:13
I've set a breakpoint in the following WebMethod but I'm never hitting the breakpoint. cs: [WebMethod] public static string search() { return "worked"; } aspx: function search() { $.ajax({ type: "POST", url: "ProcessAudit/req_brws.aspx/search", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { alert(msg) } }); } <button id = "btnSearch" onclick = "search()" >Search</button> Make sure that you have enabled page methods in your ScriptManager element: <asp:ScriptManager ID="scm" runat="server" EnablePageMethods="true" /> and that you have

jQuery AJAX call to an ASP.NET WebMethod

ε祈祈猫儿з 提交于 2019-11-26 07:46:51
问题 I have the following jQuery AJAX request: function sendUpdate(urlToSend) { var code = AccessCode; var url = urlToSend; var options = { error: function(msg) { alert(msg.d); }, type: \"POST\", url: \"webmethods.aspx/UpdatePage\", data: \"{ accessCode: \" + code + \", newURL: \'\" + url + \"\' }\", contentType: \"application/json; charset=utf-8\", dataType: \"json\", async: true, success: function(response) { var results = response.d; } }; $.ajax(options); } And the corresponding ASP.NET

Trying to make Web Method Asynchronous

自作多情 提交于 2019-11-26 04:56:38
问题 The project I am currently working on involves MS SQL Server and ASP.net Web Services that use Session variables. Apparently this causes a client\'s calls to execute in a sequential manner. I want to make sure that these methods execute asynchronously. After doing some research it appears to me the choicest method is to persist the session state in the database using a table that tracks sessions ( using guids say ) and separate tables for each session. Before I dive directly into this I need

“Invalid JSON primitive” in Ajax processing

女生的网名这么多〃 提交于 2019-11-26 03:10:29
问题 I am getting an error in an ajax call from jQuery. Here is my jQuery function: function DeleteItem(RecordId, UId, XmlName, ItemType, UserProfileId) { var obj = { RecordId: RecordId, UserId: UId, UserProfileId: UserProfileId, ItemType: ItemType, FileName: XmlName }; var json = Sys.Serialization.JavaScriptSerializer.serialize(obj); $.ajax({ type: \"POST\", url: \"EditUserProfile.aspx/DeleteRecord\", data: json, contentType: \"application/json; charset=utf-8\", dataType: \"json\", async: true,

ASP.NET Calling WebMethod with jQuery AJAX “401 (Unauthorized)”

青春壹個敷衍的年華 提交于 2019-11-26 02:19:37
问题 Been stuck with this for hours {\"Message\":\"Authentication failed.\",\"StackTrace\":null,\"ExceptionType\":\"System.InvalidOperationException\"} I\'m trying to call this WebMethod in my ASP.Net Webform [WebMethod] public static string GetClients(string searchTerm, int pageIndex) { string query = \"[GetClients_Pager]\"; SqlCommand cmd = new SqlCommand(query); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue(\"@SearchTerm\", searchTerm); cmd.Parameters.AddWithValue(\

Calling a &#39;WebMethod&#39; with jQuery in ASP.NET WebForms

社会主义新天地 提交于 2019-11-26 02:14:01
问题 I\'ve set a breakpoint in the following WebMethod but I\'m never hitting the breakpoint. cs: [WebMethod] public static string search() { return \"worked\"; } aspx: function search() { $.ajax({ type: \"POST\", url: \"ProcessAudit/req_brws.aspx/search\", data: \"{}\", contentType: \"application/json; charset=utf-8\", dataType: \"json\", success: function (msg) { alert(msg) } }); } <button id = \"btnSearch\" onclick = \"search()\" >Search</button> 回答1: Make sure that you have enabled page