webmethod

WebMethod not called (triggered) by PageMethod in Visual Studio 2013

痞子三分冷 提交于 2019-11-29 14:34:05
I have the following problem: The call from a WebMethod is not being done on a project created in Visual Studio 2013 (ASP.NET WebForms Application). If I create a project, for example, in Visual Studio 2008 and migrate to VS 2013 works correctly. The problem only occurs when I create a new project in Visual Studio 2013. There is no error message in the console. The WebMethod is just not being called. Nothing happens. I searched a lot but found nothing about it. ASPX code: <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="TestePageMethods._Default" %> <

How to pass json string to webmethod c# ASP.NET

末鹿安然 提交于 2019-11-29 14:13:42
Im trying to stringify a javascript object and then pass the string as a parameter to a WebMethod in Code Behind. I can't get it to work as I get a Internal Server Error of 500 and the stacktrace says that value is missing for parameter. Here is the javascript code: var jSon = JSON.stringify(javascriptObject); // "{"Foretagsnamn":"Avector","BGFarg":"000000","TextColor":"fafafa","FooterFarg":"ffffff","FooterColor":"000000","FooterLinkColor":"050505","FeaturedBorderColor":"","HoverFarg":"12ebeb","RutFarg":"0d0d0d","SelectedRutFarg":"","RutColor":"FFFFFF","LankColor":"","DelaMedSig":"1",

jqgrid jsonReader configuration

偶尔善良 提交于 2019-11-29 12:03:43
I'm new to jqgrid finally i've setup a grid. Suppose i need to setup jsonReader so that the grid knows where to get my grid-data in the json return. However i got blank cells after trying for days. Here is my grid: jQuery("#list48").jqGrid({ url: 'dbtest.aspx/get_offsite_history2', datatype: "json", mtype: 'POST', ajaxGridOptions: { contentType: "application/json" }, serializeGridData: function(postData) { return JSON.stringify(postData); }, jsonReader: { root: function(obj) { alert(JSON.stringify(obj.d)); return obj.d; }, repeatitems: false }, height: 'auto', rowNum: 30, rowList: [10, 20, 30]

Get Json Data From Asp.Net Webmethod and Consume in angularJS

荒凉一梦 提交于 2019-11-29 08:08:24
Can any one guide me how to get json data from asp.net webmethod, and consume it in angularJS. app.controller('MainController', ['$scope', function ($scope, $http) { try { $http({ method: 'GET', url: 'ProblemList.aspx/GetProblemList' }) .success(function (data, status, headers, config) { alert(data); }).error(function (data, status, headers, config) { }); } catch (e) { throw e; } I had the same issue, I tried many different ways, this is the way I found it works... ( I think the tricks is a combination of the header config, and the json parameter with "data : {}", I am not sure but It was

How to download file via jquery ajax and C#

。_饼干妹妹 提交于 2019-11-29 06:40:24
I want to download a file using jQuery Ajax web method, but it's not working. Here is my jQuery ajax call to web method: function GenerateExcel() { var ResultTable = jQuery('<div/>').append(jQuery('<table/>').append($('.hDivBox').find('thead').clone()).append($('.bDiv').find('tbody').clone())); var list = [$(ResultTable).html()]; var jsonText = JSON.stringify({ list: list }); $.ajax({ type: "POST", url: "GenerateMatrix.aspx/GenerateExcel", data: jsonText, contentType: "application/json; charset=utf-8", dataType: "json", success: function (response) { }, failure: function (response) { alert

jQuery Ajax results in undefined

白昼怎懂夜的黑 提交于 2019-11-29 05:21:27
I have a simple function which only returns a translated message from the server to the client. But the result shows undefined, when I pass the result into a var. function MessageNoResult() { $.ajax( { type: "POST", async: true, url: '<%= ResolveUrl("~/WebMethods.aspx/MessageNoResult") %>', contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { return msg.d; } }); } Result --> Undefined (bad) var message = MessageNoResult(); alert(message); When I look into the Headers it gives me: Server ASP.NET Development Server/9.0.0.0 Date Wed, 09 Nov 2011 09:01:31 GMT

How to call an ASP.NET WebMethod in a UserControl (.ascx)

拟墨画扇 提交于 2019-11-28 22:24:57
Is it possible to place a WebMethod in an ascx.cs file (for a UserControl) and then call it from client-side jQuery code? For some reasons I can't place the WebMethod code in an .asmx or .aspx file. Example: In ArticleList.ascx.cs I have the following code: [WebMethod] public static string HelloWorld() { return "helloWorld"; } In ArticleList.ascx file there I have the call to the WebMethod as follows: $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", data: "{}", dataFilter: function(data)//makes it work with 2.0 or 3.5 .net { var msg; if (typeof (JSON) !== 'undefined' &&

Calling a WebMethod using jQueryAjax “GET”

与世无争的帅哥 提交于 2019-11-28 20:32:17
i have a ajax request which works well using "POST" but when used "GET" it gives me the following error, {"Message":"An attempt was made to call the method \u0027GetSomething\u0027 using a GET request, which is not allowed.","StackTrace":" at System.Web.Script.Services.RestHandler.GetRawParams(WebServiceMethodData methodData, HttpContext context)\r\n at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.InvalidOperationException"} so here is my code, on the client side, function test() { $.ajax({ url:

Why WebMethod declared as Static?

我只是一个虾纸丫 提交于 2019-11-28 12:03:01
I declared a WebMethod in my default.aspx.cs file.. [WebMethod] public static void ResetDate() { LoadCallHistory(TheNewDate.Date); } Why must the WebMethod method be declared static? Sean Airey They're static because they are entirely stateless, they don't create an instance of your page's class and nothing is passed to them in the request (i.e. ViewState and form field values). HTTP is stateless by default, ASP.Net does a lot of stuff in the background with ViewState, Session, etc. during a standard page request to make life easier for developers. When a web method is called through AJAX, the

ASP.NET Call Code Behind Function From Javascript

五迷三道 提交于 2019-11-28 09:28:59
问题 I made a webmethod that I'm trying to call from javascript, but it doesn't seem to be firing. I'm grabbing the selected index value from a listbox inside of a usercontrol and passing it to my webmethod to delete the selected user. I've looked at countless sites and haven't found a solution. I'm not getting any errors, everything else seems to be working. I've tried calling this function from a public sub in the code behind also with no luck. Any suggestions are greatly appreciated! <%@ Page