webmethod

Page load is fired instead of web method

好久不见. 提交于 2019-12-12 15:02:37
问题 OK, so my websites been working normally up until now, I'm not really sure what I've changed. I have a jQuery AJAX call that sends a coupon code to the server, and retrieves a number (which is the discount). The Webmethod is no longer being fired though, instead the Page_load of the page which the webmethod is on is being fired. Why? What can I check? What can I do? Here is my handler for when the button is clicked $('div#code_apply_btn').click(function() { $(this).html('PLEASE WAIT');

Large binary over asmx web service

强颜欢笑 提交于 2019-12-12 14:22:27
问题 I am transfering a large zipped text file over the classic asmx web service. My reason for doing so is that the file's size is 20 MB unzipped, 4MB zipped. This is the method. I will provide additional information if necessary. [WebMethod] public byte[] Transfer() { return File.ReadAllBytes(@"4MBFile.zip"); } I am using C# and .NET 4. (I changed the initial settings for the project from 2.0 to 4.0). A webmethod uses a kind of serialization so I guess there will be some overhead. Am i really

JSON postback to c# webmethod add literal control

泪湿孤枕 提交于 2019-12-12 13:42:22
问题 I'm learning about webmethods and posting back to them using JSON, I've got the following below, but it says it can't find the webmethod (404). Can't see where I'm going wrong, thanks. In the page javascript: <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function () { $(".FilterResults").click(function () { var topic = $(".DropDownList1").val(); var number = $(".DropDownList2")

WebMethod (sometimes) returns entire website

落花浮王杯 提交于 2019-12-12 10:10:25
问题 I have a WebMethod which accepts one parameter. When I send a request to the webmethod without any parameters everything works well but when I supply a parameter to the same method, it returns entire site instead of a string. The page parameter changes nothing except the content of the list. List is just ListView which displays list of strings. When I use URLRewriting the URL is different in instances that I supply a parameter from instances when I do not. Can anybody help me with this

Webmethod can't remove Object { d: “” }

夙愿已清 提交于 2019-12-12 10:04:41
问题 What I want to do is instead of sending Object { d : "{"FileID":"1213"}" } send "{"FileID":"1213"}" My current code: using System; using System.Web.Mvc; using System.Data; using System.Data.SqlClient; using System.Configuration; using System.Web; using System.Web.Services; using System.Web.Script.Services; using System.Web.Script.Serialization; [ScriptService] partial class testing_class : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Session["FileID"] = Request

How to return HTML from ASP.Net WebMethod call using Jquery?

浪尽此生 提交于 2019-12-12 09:27:10
问题 Using Asp.Net 4.0 Web Forms and Jquery 1.6.2. I want to make an Ajax call to a WebMethod on a page and have it return html. On the server side the WebMethod looks like this. [WebMethod] public static string GetOrders() { return theMethodThatGeneratesHtml(); } and here is the calling Ajax function. function GetOrders() { $.ajax({ type: 'POST', contentType: "application/json", url: "Orders.aspx/GetOrders", data: "{}", success: function (data) { $('#content').html(data); }, dataType: "text" });

Ajax call to Asp.net Web Method using Jquery

我们两清 提交于 2019-12-12 09:18:12
问题 I am using a jquery method, to send information (namely only member identification #) from client side to the server side. The server side has the traditional Web Method implemented so as to capture data sent and execute SQL queries based on it. Web-service-method-using-jQuery However until now I have been returning a single string from the server side back to the client side after the SQL query. Wondering what would be the best way to return a complicated series of strings... member

Inconsistent LinkButton PageMethod behavior in different browsers

偶尔善良 提交于 2019-12-12 08:17:34
问题 I have a LinkButton on a page that performs a post-back, but also has an onClientClick event. The idea is to set some session variables in the background from client-side data (don't ask). I've placed a break point in the web method to step through our code, and what we're experiencing is that depending on the browser, the PageMethods may return a success message, failure message, or no message at all . Additionally, the web method may or may not get called, regardless of the PageMethods

Return large string from ajax call using Jquery to Web Method of ASP.NET

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 07:49:44
问题 Inside my ASP.NET website I am calling a Web Method using Jquery as follows: $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", data: "{'param1': '" + param1 + "','param2': '" + param2+ "' }", dataType: 'json', url: "Default.aspx/TestMethod", error: function (jqXHR, textStatus, errorThrown) { alert("error: " + textStatus); }, success: function (msg) { document.getElementById("content").innerHTML = msg.d; } }); Web Method Definition is: [System.Web.Services.WebMethod]

Access WebMethod in external C# class on AJAX call

北城以北 提交于 2019-12-12 07:05:54
问题 I would like to know what url should we use on AJAX to call a WebMethod in an external C# class To call a [WebMethod] on a page's code behind by AJAX we use: url: 'default.aspx/Method' But i am being unable to access a [WebMethod] in MyClass.cs (located in /foo/) Those, for example, don't work: url: 'default.aspx/MyClass.Method' url: 'foo/MyClass.cs/Method' How can i access a WebMethod on an external C# class file? 回答1: You need to add a web accessible file to interact with the external