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

You can avoid the static constraint by using a simple .asmx page instead of the codebehind page. 1) Open New Website using the AJAX Enable ASP.NET template (it puts the necessary references in the web.config) 2) SIMPLESERVICE.ASMX – Add a new .asmx web service (I called mine SimpleService.asmx) Notice the [System.Web.Script.Services.ScriptSerive] decoration and that the … Read more

Getting RAW Soap Data from a Web Reference Client running in ASP.net

I made following changes in web.config to get the SOAP (Request/Response) Envelope. This will output all of the raw SOAP information to the file trace.log. <system.diagnostics> <trace autoflush=”true”/> <sources> <source name=”System.Net” maxdatasize=”1024″> <listeners> <add name=”TraceFile”/> </listeners> </source> <source name=”System.Net.Sockets” maxdatasize=”1024″> <listeners> <add name=”TraceFile”/> </listeners> </source> </sources> <sharedListeners> <add name=”TraceFile” type=”System.Diagnostics.TextWriterTraceListener” initializeData=”trace.log”/> </sharedListeners> <switches> <add name=”System.Net” … Read more

Calling an ASP.NET server side method via jQuery

To call ASP.NET AJAX “ScriptServices” and page methods, you need to use the full $.ajax() syntax: $.ajax({ type: “POST”, url: “MessagePopup.aspx/SendMessage”, data: “{subject:'” + subject + “‘,message:'” + message + “,messageId:'” + messageId + “‘,pupilId:'” + pupilId +”‘}”, contentType: “application/json; charset=utf-8”, dataType: “json”, success: function(msg) { // Do something interesting here. } }); See this … Read more

How to let an ASMX file output JSON

To receive a pure JSON string, without it being wrapped into an XML, you have to write the JSON string directly to the HttpResponse and change the WebMethod return type to void. [System.Web.Script.Services.ScriptService] public class WebServiceClass : System.Web.Services.WebService { [WebMethod] public void WebMethodName() { HttpContext.Current.Response.Write(“{property: value}”); } }