473,659 Members | 2,996 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling a WebService method from JQuery within a .NET UserControl

1 New Member
Hi,

I have the following script within a user control

Expand|Select|Wrap|Line Numbers
  1.     <script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
  2.     <script type="text/javascript">
  3.  
  4.         jQuery().ready(function() {
  5.  
  6.             $("#btnNext").click(function() {
  7.  
  8.                 var options = {
  9.                     type: "POST",
  10.                     url: "/services/UserServices.asmx/ValidateFields",
  11.                     data: "{}",
  12.                     contentType: "application/json; charset=utf-8",
  13.                     dataType: "json",
  14.                     success: function(ret) {
  15.                         alert(ret);
  16.                     }
  17.                 };
  18.  
  19.                 $.ajax(options);
  20.             });
  21.         });
  22.            </script>
  23.            <input id="btnNext" type="button" value="Next"  />
  24.  
  25.  

When I add the user control to a test page and click the button, nothing happens.

If I move this code to the test page itself (default.aspx), clicking the button calls the web method and returns successully.

So, I conclude that it isn't possible to do this within a user control which seems rather restrictive.... ...or am I missing something?

Any help....most appreciated!


Kind Regards


Richard.
Feb 4 '10 #1
2 6033
Frinavale
9,735 Recognized Expert Moderator Expert
I think it has to do with your URL.
Try providing an absolute URL to the web service....

-Frinny
Feb 8 '10 #2
Shooby
1 New Member
Just in case anyone else stumbles across this looking for the same answer, check out http://stackoverflow.com/questions/5...d-using-jquery It states that this cannot be done as the ascx form does not represent a real URL.
Sep 26 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2057
by: kingofkolt | last post by:
hi all, just wondering what the syntax is for calling a method of a class from another method of that same class? for example... class Test { var $test="foo"; function printTest() {
8
5356
by: Brett Robichaud | last post by:
I understand how code-behind can handle events for a page, but can I call a code-behind method from within a <script> tag in my ASP.Net page, or can I only call methods defined in other <script> sections? I can't seem to figure out the syntax for for calling code-behind directly. The method is within the class my page inherits from and is public, but when I try to call it from my page I get this error: CS1520: Class, struct, or...
3
3556
by: Merav Orion via .NET 247 | last post by:
I have a problem calling webservice from client side javascript. The javascript call the settimeout() method. when the user press submit button it ignore the press and keep refreshing the page. it looks like the data is not transferred to the asp page from the web service. just after going to internet option -> security -> Custom level -> Access data sources across domains -> and check the enable radio -> the problem is fixed. I need a...
3
12880
by: Henrik | last post by:
Hi all,,, I need to get a refferece to a XML-webservice, and get some data from it.... But I can't add it like an web-refference... What options does I else have?? I've been told that i've to use SOAP, to connect to it, but how?? Are there any good documentation for that?? all the examples that i've found, is using web-refference.. Thanks
2
5120
by: MSNews | last post by:
Hi, I have written a WebService using Visual Studio.Net's 'ASP.Net Web Service' project (ASMX). I want to call the exposed methods form a HTML client (using JavaScript) as a function. I do not want to prepare the Xml and make a SOAP call. One way is to use the webservice.htc but it will not work on Netscape. Can somebody suggest me some other solution through which I can make method calls ? regards, Tushar
4
1240
by: Craig | last post by:
Hi All, One of our customers wrote an application in Visual Studio 2005 and is trying to use our webservices that was built with Visual Studio 2003. He reports that the call to the method always times out. If he uses the same code in Visual Studio 2003 it works fine (it's a simple sign-in method with 2 string parameters for user id and password). Does anyone know why there is an issue with a VS2005 app calling a webservice method...
1
1134
by: Ace | last post by:
Hi all, I have a webservice method that accepts a string parameter value and returns a dataset to the caller. On the XP development machine it works ok. but on the web server runing windows 2003 and IIS 6 no values are return. no error message either. Both development machine and webserver are using MSDE 1.1 as the database. The webserver is NOT part of of a domain and it's using a local IP address. many thanks.
7
5612
by: christian13467 | last post by:
Hi, I'm using ASP.Net 2.0 with IIS 6.0 on windows server 2003 sp1. Calling a commandline program or a cmd file using Process.Start inside a webservice method. The call to Process.Start returns once after restarting the iis. A second call to my webservice method never returns. I found some post wich where fixed checking access rights. I added ASPNET to administrators group with no success.
4
7137
by: Jonathan | last post by:
I have a SQL stored procedure for adding a new record in a transactions table. It also has two return values: CounterID and IDKey. I want to create a webservice that accepts the 10 input parameters and returns the two return values. My C# programmer here says that webservice methods can only return 1 value per method. Is that right? Though I haven't ever created a webservice, I would have thought that a method could return a whole lot...
2
1532
by: E11esar | last post by:
Hi there. I have written an ASP.Net web page in C# and have also create a corresponding WebService that will return DataSets to the web application as required. This all works fine when I have the Web Service and web site running via their own Visual Studio sessions, but once I publish these projects and load them into respective directories in IIS, I receive the following error when the client web applicatioon makes a call to the Web...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8747
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8528
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8627
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7356
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6179
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.