webmethod

Download File from C# through Web Method via Ajax call?

╄→尐↘猪︶ㄣ 提交于 2019-12-19 03:16:34
问题 I have tried to download the file from the server through the webmethod but it has not work for me. my code as below [System.Web.Services.WebMethod()] public static string GetServerDateTime(string msg) { String result = "Result : " + DateTime.Now.ToString() + " - From Server"; System.IO.FileInfo file = new System.IO.FileInfo(System.Web.HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["FolderPath"].ToString()) + "\\" + "Default.aspx"); System.Web

.NET Overload WebMethods - Possible?

主宰稳场 提交于 2019-12-19 03:14:52
问题 I have two web methods which I wish to overload: <WebMethod()> _ Public Function GetProject(ByVal id As Int32) As Project <WebMethod(MessageName:="GetProjects")> _ Public Function GetProject(ByVal filter As String) As Projects I read about overloading using MessageName, however I cannot get this to work. Is this possible? 回答1: Off course it is possible! do not forget to change the WebServiceBinding [WebServiceBinding(ConformsTo = WsiProfiles.None)] try this: [WebService(Namespace = "http:/

$.ajax Returning HTML of the page instead of results

烂漫一生 提交于 2019-12-19 02:54:27
问题 I wrote a simple webmethod that I call on the client side to check if a value exists in the database on text change. It works fine locally, but when I move it to our Development environment it returns the entire HTML of the page in the response. The only thing that I have noticed is that locally the Response.Server is IIS7.5, but on our Dev server it is IIS6. Here is my code: Server Code [ScriptMethod] [System.Web.Services.WebMethod] public static bool CheckInvoiceExists(string vendorNumber,

How to format JSON for asp.net webmethod that takes class parameter

若如初见. 提交于 2019-12-18 09:18:30
问题 I have the following webmethod on my asp.net code behind page: [WebMethod(EnableSession = true)] public static bool SaveFailureData(SimpleFailureData data) { } SimpleFailureData is defined as the following: public class SimpleFailureData { public int Id { get; set; } public string Comments { get; set; } public double Score { get; set; } public double Adjustment { get; set; } public List<ShutdownData> ShutdownData { get; set; } } public class ShutdownData { public int Id { get; set; } public

WebMethod not being called

六眼飞鱼酱① 提交于 2019-12-17 17:06:20
问题 I am passing a javascript variable containing a string to the server via jquery.ajax. Although the "success" condition is called, the server-side WebMethod is never called. Client: $.ajax({ type: "post", url: "Playground.aspx/childBind", data: {sendData: ID}, //contentType: "application/json; charset=utf-8", dataType: "text", success: function (result) { alert("successful!" + result.d); } }) Server: [WebMethod] public static string childBind(string sendData) { return String.Format("Hello"); }

Why WebMethod declared as Static?

萝らか妹 提交于 2019-12-17 16:44:32
问题 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? 回答1: 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

How to get data from C# WebMethod as Dictionary<> and display response using jquery ajax?

*爱你&永不变心* 提交于 2019-12-14 03:29:34
问题 Here is return type I want to return Dictionary<ReportID, ReportDatail> where structure of classes as: Class ReportDetail { ReportID, ReportName, ReportShortName, List<ReportFields> } Class ReportFields { SystemName, DBName, DataType, MaxLength, DefaultValue } I don't have any idea about how to return that response as dictionary. function GetReportsDetails(AccoutType) { $.ajax({ type: "POST", url: '<%= ResolveUrl("~/Web/ReportPosition.aspx/GetReportDetail") %>', contentType: "application/json

Using jQuery to directly call ASP.NET AJAX page methods — 500 (Internal Server Error)

我们两清 提交于 2019-12-14 03:12:26
问题 I'm learning about asp methods via ajax and... So I tried doing the ff. from this site: http://encosia.com/using-jquery-to-directly-call-aspnet-ajax-page-methods/ In JS file: $(document).ready(function () { // Add the page method call as an onclick handler for the div. $("#Result").click(function () { $.ajax({ type: "POST", url: "WebForm1.aspx/GetDate", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { // Replace the div's content with the

WebMethod not accessible in Sitecore

心不动则不痛 提交于 2019-12-14 02:17:03
问题 I got a problem for a website I was working on. A WebMethod is called from a JavaScript function: var ajaxOptions = { url: "/layouts/foobar/Foo.aspx/GetBar" } $.ajax(ajaxOptions).done(function(result) { loadResult(result, a); }); The method GetBar in Foo.Aspx looks like this: [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public static object GetBar() { return FoobarManager.GetItems(); } The function returns a valid JSON object. Sitecore is used in the FoobarManager. Example

Extract words from a string and verify whether or not they exist in a database in VB

纵然是瞬间 提交于 2019-12-13 20:39:22
问题 I am trying to create a web-method to check whether a string contains a word which is in a list of 'not allowed' words. This list will be updated from time to time. <System.Web.Services.WebMethod()> _ Public Function checkword(ByVal Id As String) As String Dim returnValue As String = String.Empty Dim s As String = Id ' Split string based on spaces Dim words As String() = s.Split(New Char() {" "c}) Dim rer As Integer Dim word As String For Each word In words 'call class file Dim oscar As New