pagemethods

Pass Array of Javascript objects to PageMethod

五迷三道 提交于 2019-12-07 17:24:47
问题 Here's the situation: I would like to iterate through a table with input controls, collect up the values and then submit them to an ASP.Net PageMethod to save the data to the database. I have the collection all figured out, but am getting an error that the string can't be converted to a Dictionary. So I end up with something like this being passed to a method with the below signature [ { 'id': '383840923', 'name': 'fred', 'car':'honda' }, { 'id': '243', 'name': 'joe', 'car':'honda' }, { 'id':

ASP.NET AJAX PageMethods call load whole page for .NET 4.5 IIS 7.5

岁酱吖の 提交于 2019-12-07 08:44:06
问题 I am calling pageMethod in codebehind of aspx page. I get the response for whole page instead of webMethod response. Also, I tried calling the same webMethod using jquery and got the whole page as response. Client: <asp:ScriptManager ID="scriptManager1" runat="server" EnablePartialRendering="True" EnablePageMethods="true" EnableScriptGlobalization="true" EnableScriptLocalization="true" > function TestNumber() { PageMethods.getNumber(ResponseTest); } function ResponseTest(response){ var num =

Getting Exception Details from ASP.NET PageMethods on the Client SIde

我的梦境 提交于 2019-12-07 04:54:53
问题 I am having a pagemethod to which i give a call from my JavaScript say Pagemethods.MyMethod(MyParameter, onsucess, onfailure); In the Code behind, I have something like this: [WebMethod] public static void MyMethod(Param) { try{ //DoSomething.. } catch(exception ex) { //Log the exception and rethrow throw new exception(ex.innerexception); } } Now the issue i face is : Whenever i do get an exception, i re throw the exception from code behind But in the onfailure method, i just get a generic

String exceeds maxJsonLength with less than 250kb

雨燕双飞 提交于 2019-12-06 08:41:08
问题 I'm using an entity together with ajax. I want the full table i provice with Entity framework ina grid created with JavaScript. The table I'm currently sending has less than 140 lines. My code works if I only have 50 lines in the table a few more an I get the following error: {"Message":"Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.","StackTrace":" at System.Web.Script

Page Method calls from jQuery to Sharepoint

无人久伴 提交于 2019-12-06 05:51:36
问题 I have an application page (aspx) deployed in the _LAYOUTS folder of MS SharePoint 2010. I would like to call a method inside that page marked with the [WebMethod] attribute using jQuery. I am using the following code on document.ready() : $("#btnOk").click(function () { var theUrl = '/_layouts/MyProject/MyPage.aspx/MyMethod'; $.ajax({ type: "get", dataType: "json", url: theUrl, data: {}, success: function (response) { [...] }, error: function (xhr, textStatus, errorThrown) { [...] } }); });

window.location change fails AJAX call

人盡茶涼 提交于 2019-12-06 02:10:45
问题 I've got a click tracking AJAX function (calls a WebMethod on an .aspx page), and I need to call it when the user clicks through to a link. Unfortunately, I'm using window.location = "newUrl" to change the page, which seems to make the AJAX call fail. Is there a way around this? I do not need to get any information back from the AJAX call, I just need to make sure the WebMethod is called. I'm aware that I could just redirect on the success() or failure() calls, but then I would have to wait

Pass Array of Javascript objects to PageMethod

时光总嘲笑我的痴心妄想 提交于 2019-12-05 21:11:25
Here's the situation: I would like to iterate through a table with input controls, collect up the values and then submit them to an ASP.Net PageMethod to save the data to the database. I have the collection all figured out, but am getting an error that the string can't be converted to a Dictionary. So I end up with something like this being passed to a method with the below signature [ { 'id': '383840923', 'name': 'fred', 'car':'honda' }, { 'id': '243', 'name': 'joe', 'car':'honda' }, { 'id': '4323423', 'name': 'paul', 'car':'honda' }, { 'id': '38384234230923', 'name': 'ted', 'car':'honda' },

How to stop a page refresh in angular 2 within aspx

北城以北 提交于 2019-12-05 18:39:49
The pagemethod works, however when I use the webmethod it refreshes the page destroying the reason to use angular 2 in the first place. How do I prevent the form from refreshing the page? index.aspx <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManagerMain" runat="server" EnablePageMethods="true" > </asp:ScriptManager> <my-app>Loading...</my-app> </form> </body> index.aspx.cs [WebMethod] public static string getString() { return "Test"; } app.component.html <div> <Button (click)="btnSubmit_Click">test</Button> </div> app.component.ts btnSubmit_Click() { var test = window

ASP.NET AJAX PageMethods call load whole page for .NET 4.5 IIS 7.5

╄→гoц情女王★ 提交于 2019-12-05 15:04:42
I am calling pageMethod in codebehind of aspx page. I get the response for whole page instead of webMethod response. Also, I tried calling the same webMethod using jquery and got the whole page as response. Client: <asp:ScriptManager ID="scriptManager1" runat="server" EnablePartialRendering="True" EnablePageMethods="true" EnableScriptGlobalization="true" EnableScriptLocalization="true" > function TestNumber() { PageMethods.getNumber(ResponseTest); } function ResponseTest(response){ var num = response.d; } CodeBehind: [WebMethod] public static int getNumber() { return accountNumber; } I am

Getting Exception Details from ASP.NET PageMethods on the Client SIde

穿精又带淫゛_ 提交于 2019-12-05 11:06:41
I am having a pagemethod to which i give a call from my JavaScript say Pagemethods.MyMethod(MyParameter, onsucess, onfailure); In the Code behind, I have something like this: [WebMethod] public static void MyMethod(Param) { try{ //DoSomething.. } catch(exception ex) { //Log the exception and rethrow throw new exception(ex.innerexception); } } Now the issue i face is : Whenever i do get an exception, i re throw the exception from code behind But in the onfailure method, i just get a generic message saying that "the server method MyMethod failed with following error: " I don't seem to get the