AJAX :: Unable To Call The Service Using Scriptmanager And Js?
May 21, 2010
I'm not able to call a service using the scriptmanager and javascript. But when I include the service into the project i call it. but when i seperate it in another project. I'm not able to call.
<asp:ScriptManager runat="server" ID="sm" EnablePageMethods="true" EnableScriptGlobalization="true">
<Services>
<asp:ServiceReference Path="http://localhost:2794/Service1.svc" InlineScript="false" />
[code]...
View 1 Replies
Similar Messages:
May 13, 2010
Configuration : Windows Vista,VS 2005,Ajax v1.0.61025 My Html Page
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<script language="javascript" type="text/javascript">
function fnCall()
{
try
{
var ans= Sim.Service.HelloWorld(OnMethodSucceeded, OnMethodFailed);
}
catch(e)
{
alert(e.message);
}
}
function OnMethodSucceeded(result)
{
alert('a');
}
function OnMethodFailed(result)
{
alert('b');
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" ><Services>
<asp:ServiceReference Path="http://localhost/ajaxtest/service.asmx" /></Services>
</asp:ScriptManager>
<div><input id="Button1" type="button" value="button" onclick="fnCall();" /></div>
</form>
</body>
</html>
Web Service CS.
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;
namespace Sim
{
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class Service : System.Web.Services.WebService
{
public Service()
{
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod,ScriptMethod(UseHttpGet=true)]
public string HelloWorld()
{
return "Hello World";
}
}
}
But i am getting Sim is not defined. Error. post ur comments. I have reviewed most of the forums. I am not able to clear
View 13 Replies
Feb 8, 2011
I have a user control with both an UpdatePanel and a ScriptManager.
Some pages in the system have a ScriptManager of their own, and need to include the UserControl.
This throws the "You can only have 1 ScriptManager" exception.
If I remove UserControl's ScriptManager, I'll get 'UpdatePanel1 requires a Script Manager" exception.
I've tried to modify the UserControl to dynamically include it's own script manager if none exists. But all the methods I've used before involve adding a delegate to Page.OnInit-- which won't work, since the UserControl Init fires first.
Because the system designers here like making my life difficult, I can't create a MasterPage, or a BasePage for the system in inherit off of. I'd be stuck going to each page an adding a ScriptManager before the UserControl on each of them. Is there any way of, in the UserControl, detecting if the page has a ScriptManager, and if not, adding it dynamically in a way that makes the UpdatePanel happy?
View 3 Replies
Jan 12, 2011
I have deployed a custom SharePoint Web service on Farm A. I am trying to access this Web service from a SharePoint timer job on Farm B. On Farm B, I am creating Class Library project, packaging it (wsp) and then deploying to GAC. The problem is I'm unable to access the Web Service using the following code. TodaysNewSVC is a service reference
TodaysNewSVC.GetTodaysnewsfromInsite objGetNews = new TodaysNewSVC.GetTodaysnewsfromInsite();
objGetNews.PreAuthenticate = true;
objGetNews.Credentials = CredentialCache.DefaultCredentials;
objGetNews.Url = "http://insite-dev.portal/_vti_bin/todaysnews.asmx";
DataTable dt2 = objGetNews.getNewsFromInsite(true, true);
//getNewsFromInsite is a WebMethod which returns the DataTable.
Note: Both farms use the same active directory authentication. I have also done the debugging for Timer Job and feature activation and they are working fine. The problem occurs during the call i.e. getNewsFromInsite
The asmx and wsdl files are accessible from Internet Explorer and also from Windows Console application. Here is the code which I use from console application:
GetTodaysnewsfromInsiteSoapClient objWSClient = new GetTodaysnewsfromInsiteSoapClient();
objWSClient.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;[code]...
Here is the error message:The request failed with the error message:
--
<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="%2fPages%2fproblem-with-page.aspx%3fc%3d500">here</a>.</h2>
</body></html>
View 1 Replies
Apr 6, 2010
I am using ASP.Net 3.5. I have fiiled dropdown list in javascript using ajax service but unable to get its selected value in button click event on server side.
View 1 Replies
Jun 22, 2010
I am new to WCF, I was using web service asmx before. I have trouble on making my wcf JSON ajax service work through http like asmx.Could you help me see what wrong in my code?My WCF services are defined in my website application folder. My aim is to call this service in my aspx page java-script code and return complex object back as JSON to my javascript. I have no problem on doing this through classic asmx web service.
When I try to test it through my browser by type this in the URL , URL-http://localhost:3849/WebServices/Account/WCFCompanyService.svc/GetAll. it return "Method not allowed."
But if I type just this URL-http://localhost:3849/WebServices/Account/WCFCompanyService.svc, it return this:
WCFCompanyService Service
You have created a service.To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax:
svcutil.exe URL-http://localhost:3849/WebServices/Account/WCFCompanyService.svc?wsdl
This will generate a configuration file and a code file that contains the client class. Add the two files to your client application and use the generated client class to call the Service. For example:
C#
class Test { static void Main() { HelloClient client = new HelloClient();
[Code]....
This is my Ajax-enabled WCF service code:
[Code]....
This is the web.config service model setting
[Code]....
View 1 Replies
Apr 26, 2010
I'm going on my 3rd day trying to get my Ajax AutoComplete textbox to call my web method. Based on my google searches, I'm not alone. I suspect the problem has something to do with the ServicePath property on the extender, although I'm not sure. My web service is at the same level, on the same server as my test web page. I'm not sure exactly what should go into the ServicePath property, although I think I've tried every possibility. Below is my web service followed by my script.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Configuration;
using System.Web;
using System.Web.Services;
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using AjaxControlToolkit;
using System.Text;
using System.Xml;
using System.Xml.XPath;
using System.IO;
using System.Collections.Specialized;
using System.Web.Services.Protocols;
[WebService(Namespace = [URL])]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class Service : System.Web.Services.WebService
{
public Service()
{
}
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public string[] AutoCompleteNames(string prefixText, int count)
{
System.Data.SqlClient.SqlConnection cxn = new System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings["HumanResourcesConnectionString"].ConnectionString);
cxn.Open();.....................
View 11 Replies
Feb 13, 2010
I have developed a wcf service for asp.net ajax client. It includes the following steps.
(1) Created WCF sevice contract with the operation "DoWork()" which will take string as input and retun string as output.
(2)Implemented the above operation contract(attributed the implementation class with aspnetcompatibility requirement as enabled).
(3)Added the webscriptenabled to endpoint in web.config file.
(4)Hosted the wcf servie.
(5)Downloaded the javascript file from the service.(e.g.,http://localhost/service1.svc/js)
Client
(1)Opend new asp.net webapplication.
(2)Added the downloaded .js file.
(3)Given the scripts path for ajaxscript manager as both .js file and service url.
e.g
<asp:ScriptManager
ID="id1"
runat="server">
<Scripts>
<asp:ScriptReference
Path="http://localhost:3443/Service1.svc/js/"
/>
<asp:ScriptReference
Path="~/js1.js"
/>
</Scripts>
</asp:ScriptManager>
(4)With this I am unable to call service method
View 2 Replies
Jan 28, 2011
I have this Aja.svc in my root folder
[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Aja
{
[WebGet]
[OperationContract]
public string Hi()
{
return "hi world!";
}
}
and I'm trying to do this: $.get('Aja.svc?method=Hi', function(d) { alert(d.d); }); In firebug I see that the result is HTTP Error 404.17 - Not Found The requested content appears to be script and will not be served by the static file handler. I use .net 3.5, jquery 1.4.4
View 1 Replies
Jan 13, 2011
I created a number of standard WCF Services (Service Contract and Host (svc) are in separate assemblies). I fired up a Web Site in IIS to host the Services (i.e., address is [URL]). Then in my Web Site project I added the reference. I am able to call the services normally. I am needed to call some of the services client side. Not sure if I should be looking at articles calling WCF services through AJAX, JQuery, or JSON enabled WCF Services. Some of the changes I made was adding the following to the Operation Contract:
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "SetFoo")]
void SetFoo(string Id);
Then this above the implementation of the interface:
[AspNetCompatibilityRequirements(RequirementsMode =
AspNetCompatibilityRequirementsMode.Allowed)]
Then in the service webconfig I have this (parens are angle brackets):
<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
<baseAddressPrefixFilters>
<add prefix=[URL]>>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
<serviceHostingEnvironment multipleSiteBindingsEnabled="false" />
Then in the client side I attempted this:
<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
<compositeScript>
<Scripts>
<asp:ScriptReference
Path=[URL]/>
</Scripts>
</CompositeScript>
</asp:ScriptManagerProxy>
I am attempting to call the service like this in javascript: wcfservices.SetFoo(string Id); Nothing is working. If it is idea or a better solution to call JSON enable, JQuery, etc.... I am willing to make any changes.
View 1 Replies
Jan 25, 2011
it is possible that AutoCompleteExtender can call a service Web of another project of my solution?
View 1 Replies
Oct 1, 2010
I am using an AJAX dropdownlist control with two dropdownlist. Instead of using a webservice to populate the data, I used the pagemethod to populate. My problem is the second droplist won't populate. I get a server error, 500 in the droplist. The first droplist populates fine.
BUT here's the real kicker. If I reverse the order of the public static function such that GetHelloList2 comes BEFORE GetHelloList1 in the code, then the GetHelloList2 works ...... it just seems like it is only firing one pagemethod event and allowign only one.
[URL]
View 5 Replies
Aug 4, 2010
I have one ajax call web service, and want to add some http headers using javascript, can we do that use setrequestheader in ms ajax?This is my javascript
[Code]....
[Code]....
View 3 Replies
Nov 17, 2010
I know this is a pretty common issue as i have read a lot of posts from people with similar issues. However thus far what i have uncovered doesn't seem to help resolve my issue. I have used the ModalPopupExtender regular enough but this is my first time needing the Dynamic side of things. The code I have is very basic and generic at the minute..I have the following ASPX code in place:
[Code]....
Now just to say at this stage the Modal Dialog box pops up and closes 100%. So my ProductPopulate.asmx service at the moment for testing is just using the VS2010 default Web Service with a few changes that i will explain.
[Code]....
So the changes i have made to the default VS2010 webservice is from this article http://sandblogaspnet.blogspot.com/2009/07/working-with-modal-popup-extender.html
I changed the default HelloWorld method to static and also uncommented the following line
[Code]....
So this is as far as my code has gotten at the minute. The Modal Dialog pops up 100% and what i would expect to see within the dialog box would be the text "Sampling Control" from the DynamicContextKey. Instead what i get is the "Web Service call failed: 500" error. I have stripped everything back to basics as you can see.. but for some reason i am still getting this error. I have used Web Services before from time to time without any issues and i have used the ModalPopupExtender without any issues.. but i am left scratching my head as to what i am missing on putting the two together.
Also just to note, both ASMX and ASPX files are currently in the root of the web project to rule out any path issues. Also i am using the VS Web Service to preview and debug.
View 5 Replies
Jan 1, 2010
I'm just learning MS ajax and am having problems getting a relatively simple test to work. I'm attempting to call a web service (of the .asmx variety) to return a very simple 3-column table to render in a dataView in an .aspx page. I've successfully created a working service and can by stepping through the service code it's getting the data correctly. The problem I'm having is that it stops with an exception in MicrosoftAjaxDebug.js on this line:
[Code]....
where my user_table contains 3 columns: user_name, user_key, user_ID. Real simple.My test.aspx page to get this data looks like this:
[Code]....
One more thing, I'm a little confused between the two downloads I've found, "MicrosoftAjaxLibrary_Preview6.zip" and "AspNetAjaxLibraryBeta0911.zip". From what I can tell, the latter contains all the old Ajax toolkit gadgets as well as the MS Ajax scripts. Is the MS Ajax download just a refresh of the ajax scripts in the Asp.Net ajax library? I've installed and am using the preview 6 scripts for my website.
View 3 Replies
Feb 22, 2011
I have this method in asp.net ajax enabled mvc service
[OperationContract]
public TestRun GetTestSuite(string testSuitName) {
TestRun testRun =
AdapterFactory.CreateTestRunAdapter().GetByTestSuiteName("testSuit");
return testRun;
}
Where TestRun is Created using entities framework against TestRun table. I am using following ajax method
function getTestSuite() {
$.ajax({
type: "POST",
url: "Services/TestRunService.svc/GetTestSuite",
data: '{"testSuitName" : "' + testSuiteName + '"}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
},
//If the call fails
error: function (xhr, textStatus, errorThrown) {
alert(errorThrown);
}
})
}
I get undefined error. If I return string from service it works. Do I need to change dataType: "json" to something else?
View 1 Replies
Mar 2, 2010
In a web page, I call a web service (located in the sub folder WebServices) with ajax asp.netHere my aspx code:
[Code]....
My web site uses integrated windows authentication and all works fine.However, my web service doesn't need authentication and in order to not have 2 requests (because of http code 401), I've allowed anonymous access on the WebServices folder. Doing this, I get the folowing error message when I call a web method: "Invalid web service call, missing value for parameter: user"When I look at my body request with Web Development Helper, I can see {"user":"toto"}. So, I don't understand why it's not working.Another weird thing: when I run Fiddler2 instead of Web Development Helper, every thing works fine. I turn off Fiddler2, and it doesn't work any more.
View 1 Replies
Dec 27, 2010
Some of my customers using Internet Explorer can't use my website because the call to my .net webservice failed. Under FF and Chrome no problem. For most of my customer using IE, it's working fine also but not for all...
I have isolated a call to the webservice that failed
[Code]....
I can't find why it's not always working with IE. I'm not able to get the error on my computer (even by changing security, privacy settings in IE).
View 3 Replies
Feb 2, 2010
I have a web service/wsdl file that requires client authentication to passed through SOAP headers.
There is not property or method available in web service to set the SOAP headers.
how to call the web service method along with SOAP headers in .NET 2.0
View 7 Replies
Nov 6, 2010
Iīm using jQuery to make the ajax calls to web services. Iīm not using json, I want the information in XML. If I donīt pass parameters and I make the WS parameter less it works but if I want to pass a value as parameter (I tried int and string) it doesnīt work. Here is my code:
jQuery: [Code]....
The web service
[Code]....
The error that I get from firebug is an exception System.InvalidOperationException and it says that the parameter region_id is missing.It canīt be very difficult because it works without parameters but all the information I find in internet
View 5 Replies
Jun 18, 2010
I'm working on an asp.net app and I have some controls that are created dynamically on the OnInit event. One of that controls is an asp button that has been working fine until now. When I add a ScriptManager to my page, that same button is unable to postback. It's only working if a take the ScriptManager out. Has anything like this ever appened to somebody else? Am I invalidating the page somehow? Edit: This is my script manager tag:
<asp:ScriptManager ID="ScriptManager1" runat="server"
EnablePageMethods="true" EnableScriptGlobalization="true"
EnableScriptLocalization="true">
</asp:ScriptManager>
//My Dynamic Button:
Button button1 = new Button
{
ID = "button1",
Text = "Ok"
};
button1.Click += new EventHandler(Button1_Click);
View 2 Replies
Feb 16, 2011
i am running with an unfamilier issue with jquery ajax and wcf service . i have created a simple wcf service and trying to show it on a asp.net label... the wcf service just returns a string which has to b shown on a label. the url has been set on jquery ajax url to call the wcf service using rest. but somehow i am not getting the desired thing done . the ajax cannot retrieve the data from the wcf service , here are the code snippets.
The Ajax Portion in default.aspx :
[Code]....
The Service Contract for WCF :
[Code]....
The implemented Method :
[Code]....
and the Web.Config :
[Code]....
can someone figure out here i am going wrong .... that the ajax is unable to retrieve the data from the above wcf Service .. its just a very basic and simple one .. but unable to figure out the Real Prblem.
View 1 Replies
Apr 4, 2011
When I was reading the blog Using jQuery to Consume ASP.NET JSON Web Services
I have seen this argument:
"By using jQuery to call the web service directly, we've eliminated over 100 KB of JavaScript and three extra HTTP requests. "
Why does the ASP.NET AJAX call to a .NET Web-Service needs 3 extra HTTP requests? What are those requests? (I wonder how jQuery manages the call with lesser HTTP requests in this case).
View 2 Replies
Dec 4, 2014
I am trying to call a web service function within my own ASP.net (code behind) using AJAX on the page.
Once i push the button to execute the JS/AJAX/codebehind - I got an error.
POST http://************/admin/Admin.aspx/getDBInformation 500 (Internal Server Error)
This is my code below that I am currently using:
Code:
<WebMethod> _
Public Shared Function getDBInformation() As String
loadDBData()
Return JsonConvert.SerializeObject(dbInfo, System.Xml.Formatting.Indented)
End Function
End Class
The code behind looks like this:
Code:
Imports System.DirectoryServices
Imports System.Security.Principal
Imports System.Net
Imports System.Drawing
Imports System.IO
Imports System.Data.SqlClient
Imports System.Web.Services
Imports Newtonsoft.Json
[Code] ......
How can I correct this issue so that I am able to call **loadDBData()** without that 500 error?
View 2 Replies
Feb 24, 2011
I have three cascading dropdowns on my web page and they work fine. The issue I am facing is that there are other controls on the page which cause a postback and with each postback the cascading drop downs are being re-populated (service methods are called) which is becoming a performnace issue.
View 1 Replies