AJAX :: Web Services (learning), How To Call Web Method Without [ScriptService]
Jul 6, 2010
This thread is more about learning, actually I have a web service which just returns string. I have been calling this service from code behind and updating lable with the string received from the web service.
Now I want to call web service using JavaScript. As far as I know, I have to add <asp:ScriptManager..../>. Second I have to add [ScriptService] to the web service.
But I don't wat to add <asp:ScriptManager..../> and [ScriptService].
Is there any way to call web service using javascript without adding <asp:ScriptManager..../> and [ScriptService]
Also, I am kind of lost in SOAP, JSON. I am not getting where I actually use SOAP, JSON. Using <asp:ScripManager../> and [ScriptService], I actually didn't see use of SOAP, JSON.
Above subjected error start commig in my project. I dont know why it happen suddenly but same code is working on my hosting server and website is working fine. Actually my Laptop was not working properly so I make backup my all codes and cut and copt to my external drive. Now when my laptop start working I copy back my codes but when I try to run the web application following error start showing me
Server Error in '/Q8Movie' Application.
Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: BC30002: Type 'Script.Services.ScriptService' is not defined.
I created a small new webservice for AutoCompleteExtender and for some reason I am getting "type System.Web.Script.Services.ScriptService is not defined" error. I Googled this and found a few threads about similar issues but was unable to resolve mine. Here is the example of the code:
[Code]....
When I add Imports System.Web.Script.Services I get "Namespace or type specified in the Imports 'System.Web.Script.Services' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases".
I've tried adding Reference to System.Web.Extensions and it didn't do anything. What could be the problem?
I have created a web service. When I check the service directly from it's web page it works correctly. Here's what the code looks like:
using System; using System.Collections.Generic; using System.Web; using System.Web.Configuration; using System.Runtime.Serialization; using System.Web.Services; using System.Web.Services.Protocols; using System.Web.Script.Services; using System.Runtime.Serialization.Json; using System.IO; using System.Text; using Microsoft.SharePoint; using System.Collections; namespace MDA.WebParts.SPRolodex_Web_Service { [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [ScriptService()] public class SPRolodex_Web_Service : System.Web.Services.WebService { public SPRolodex_Web_Service() { } [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public bool ListExists(string personalUrl, string listName) { try { SPSite mySite = new SPSite(personalUrl); SPWeb web = mySite.OpenWeb(); SPList list = web.Lists[listName]; return true; } catch (ArgumentException) { return false; } } } }
However, when I call the method using ServiceProxy.js (a jQuery based library) I get this error
"Only Web services with a [ScriptService] attribute on the class definition can be called from script."
As you can see the class has the ScriptService attribute and the methods have the ServiceMethod attribute.
I`ve tried rearranging them, or deleting some of them, but I always get this error on the last decleration and there`d be a blue error checking underline at the ending "> _" piece:
Error 1
Attribute specifier is not a complete statement. Use a line continuation to apply the attribute to the following statement.
From client side, I need to call a server method that is not static. For example, I got the following user control ucData (private instance of code-behind) that is Databind in the load event. The server method I need should return ucData.IsValid(). So it can't be static
In our application we have a scenario where we need to display a panel using modalpopupextender after performing an async call on the server. We were using the Show method for displaying the popup. It used to work fine without any async call. But when an async call was introduced during the request processing the popup is not getting displayed.
Can I call Ajax.BeginFrom from a custom helper method ?
AjaxHelper is not available in a custom helper method, so I tried to pass the "Ajax" available in ViewPage to Helper method while calling it, but then in method, BeginForm is not available on that passed "Ajax" parameter.
I am using VS 2008. I am using Ajax Autocomplete extender to populate a textbox. usually there is a webservice method which populates data into the autocompletion list... but in my case, the data is coming via an instance method...
At the time of doing the autocomplete, the autocomplete calls the method, the data is getting lost in the page postback..My situation is such that I cannot use a static method to get data from database, since there is already a public instance method.I am using the technique of calling GetAutocompletionList without using a WebService method.
[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()] public static string[] GetAutoCompletionList(string prefixText, int count, string contextKey) {
I am trying to call a simple method in my code behind using Jquery with Ajax. But I get a 404 not found exception everytime. Unfortunately this is a web forms solution. So I dont have all the perks of MVC
It does get into the javascript method and gives the alert but won't go into my c# method. My previous experience of using this Jquery method is in an MVC website. Is it compatible with webforms sites?
I have a web user control. That I load dynamicaly inside a modalpopup window using dynamic populate extender. User control has a external javascript file linked to it. Problem: I cannot make call to webservice method from this external javascript file. When I make a call -- servicename.methodname() I get servicename not defined error.
I have an ActiveX object which extends some functions. I have a web page that loads the ActiveX object and calls its methods in Javascript. The ActiveX object has two method; the problem is that Javascript can successfully call one of them but fails to call the other; citing Object doesn't support this property or method which is nonsense because I made a VB6.0 application that successfully calls this other method, so the two functions are indeed extended correctly and performing their job. And yes, the Internet Explorer security zones are all set and everything, as I wrote above the javascript code can call one method but refuses to call the other.