Calling a Page Method Instead of a Web service method with javascript?

Hi All,

I am just wondering if it is possible to call a page method or a static method (non webservice) with javascript and have it return the results to the calling javascript funciton just like how it is done with a webservice call? Personally I prefer not to be producing asmx's for things that may only be used on a single page.

If so ... how might I accomplish this?

If Not..... Why not?

hehe

Thanks

0
miskiw
11/2/2006 9:00:52 PM
asp.net.networking-webservices 2181 articles. 0 followers. Follow

3 Replies
979 Views

Similar Articles

[PageSpeed] 50

Hi miskiw

Yes you can do that, you can find details here

http://ajax.asp.net/docs/tutorials/useWebServiceProxy.aspx at the bottom of the page titled "To call a static page method".

It is worth noting that there is a bug with this in the current release where you can only call methods that are inline. You cannot currently make async calls to methods that are in code behind. 

HTH 

Andy. 



Andy
http://blogs.conchango.com/andrewbritcliffe
0
andybritcliffe
11/5/2006 7:03:50 PM

http://ajax.asp.net/docs/tutorials/useWebServiceProxy.aspx

can't open.

 

can you give a sample?THX


Beijing.China
0
KAI3000
11/14/2006 8:55:30 PM

The new address is: http://ajax.asp.net/docs/tutorials/ExposingWebServicesToAJAXTutorial.aspx
In the bottom of the page, you have the section Exposing Web Services from an ASP.NET Web Page.

Basically, what you need to do is to create a static method and apply the [WebMethod] attribute to it.

[WebMethod]
public static string EchoString(string name) 
{
    return "Called by " + name + ".";
}
HTH,
Maíra

This posting is provided "AS IS" with no warranties, and confers no rights.
0
maira
11/14/2006 10:19:14 PM
Reply:

Similar Artilces:

listview control with JavaScript to call the Web Method in Web Service
Hi,I'm looking to create something as clean as possible and want to do it by hand.  Unfortunately I havent done anything like this before and wondering if anyone has any sample code I could base off of ? I want to create a simple listview with a "+" and a "-"  that postback to do a database update via ajax, while incrementing a counter on the page...   any help is very much appreciated..   thanks again, mike123  I've been looking for a few days and it doesnt look like there are any examples online ..   if anyone has an...

how can I call a method in static web service method?
I have a web service method like below that I want to call a edit method in it, hiw can I do that?it cuse error in it.[WebMethod] public static string getText() { } and a method like this?  public void edit() { int a=textbox1.text  } thanx Either you have to declare edit() also as static or create an object of the class and call edit. Hi  sepideh_adi, If you want to use method of webservice, you should reference it firstly. WebSite->Add WebReference->Fill webservice url and webrefernce Name. Then you can use the webservice. webrefernceName tt=new webref...

Calling Web Service method from OnBeforeUnload method in Firefox
 I've got a page that calls a WebService method (in my application) from the window.onbeforeunload event.  It's working fine in IE7, but when I run it in FireFox (I'm using 3, haven't tried older versions), I always get a javascript alert saying "The server method 'Test' failed with the following error:".  Calling it from other places seems to work fine.  Any explanation for this behavior or suggestions of how to debug further would be greatly appreciated.  Here's a simple example that illustrates: <%@ Page Language="...

Calling a server side method from javascript without page methods
Hi everyone.  I'm trying to do some like this:  if (confirm("foo") == true) {    MyServerSideFunction(); } Of course, I can call this function using PageMethods, but since this function in my code behind shold be static, I cannot call others methods inside my class. Is there any way to call serer side methods without using PageMethods?   Thanks, and sorry for my bad english! You can use ajax to call a webservice from javascript. Check out this article on how to do it: http://www.semenoff.dk/en/Code-Corner/ASP.Net.AJAX/WebService-From-...

asynchronous call of web service method from another web service
I am calling a web service method from within another web service.  Both are called asyncrhonously. Webservice 1 is invokde from a consumer app and its completed event is assigned an event handler, this works ok  The webservice being called is itself invoking another webservice and asynchronously calling another web method, again Ive assigned an event handler to its completed event, which works.  My problem is how do i expose the ouput (a dataset) of the second web method to the first web method ? Hi, Please have a look at this article: http://msdn2.microsoft.com/en-us/li...

Calling web service method in javascript at client
 Hi,I have created one web service in c# now I want to call few method of that web service in my javascript of .aspx page.How can I call the Web service's web method in Javascript.Regards,From Nimit PatelPlease remember to "Mark As Answer" if this post answered your question! http://support.microsoft.com/?kbid=555057http://msdn.microsoft.com/msdnmag/issues/07/01/ExtremeASPNET/default.aspxGirijeshhttp://www.girijesh.in/ This is the main bit - it's a tad different because it's only be standardised in IE7...  This bit will make the request - you'll need ...

How to call web service method from aspx page.
Hi , I am new to Ajax. I am unable to call web service from aspx page. Can some one explain the what all the setting needs to be done inorder to call web service from aspx page step wise. I am trying to call but i am getting the error message as "Mywebservice" un defined. Here is the steps i followed 1) Installed the AJAX extension 1.0 2) Created web service Project As a "SampleWS" and web service class as "MyWebService" and method as "HelloWorld()" and returns string (I have added the  <ScriptService()> _ also) 3) build the projec...

New in Web Services And Page Method call
I'm here wish to get any full set of sample code of web services and page method call by using vb.net. I'm not very familiar with these two method, but i would like to learn, so wish to gain any simple example from you. compare to AJAX cascading drop down Extender, among these three, which 1 is better to reduce the frequent postback when access to a database? Any idea?Thanks for help me out ^_^ Here you can find examples and info on webservices and page methods:  http://www.asp.net/ajax/documentation/live/overview/AsynchronousLayerOverview.aspx http://www.asp.net/ajax/docume...

REST Web Service : How to call a web service method by REST way ?
Hi buddy,Can anyone tell me that how do i call a method through a web service by a REST way.I have one local application (with C#.NET, ASP.NET 2.0, SQL Server 2005) and I want to call a Web Service method which is created on a remote machine. I have to call that method from my web application by using a REST (Representational State Transfer) way. I have a WSDL file.Please provide me technical details to make this happen.I want exact code to achieve this.Please please its urgent....Thanks in advance.Thanks,Mitesh.Please Mark this as an Answer if it resolves your problem. Which Version of .n...

1 web method (page method) for multiple pages
I have a service that takes in a page method to do some stuff on the server and bring back to my client. The problem is that I have 3 more services that have to use this method... however I wish not to insert the same method each time for each service. How can I use this page method in multiple services?~Marty You can add this page web method ( its just like any other use cases for inheritance) to a base class and inherit all three pages from this, you have the web method available. HTHThajeer"Dont forget to click "Mark as Answer" on the post that helped you. This marks...

Binding a web service method call to a javascript function
(I also posed this question on the networking & web services forum, but didn't get much of a response so I'll post it here too, sorry for the double post) All,Does anyone have an example of binding (in declarative xml script) the completed event of a web service method call to a javascript function instead of a UI element? I've written a simple web control that puts a button and a text box on the page, and calls a web service when you click the button. Right now the result of the web service method call is just displayed in the text box, but I'd like to send the result t...

Binding a web service method call to a javascript function
All,Does anyone have an example of binding (in declarative xml script) the completed event of a web service method call to a javascript function instead of a UI element? I've written a simple web control that puts a button and a text box on the page, and calls a web service when you click the button. Right now the result of the web service method call is just displayed in the text box, but I'd like to send the result to a javascript function instead. Is there a way to do that? Is there a good resource on the web for xml script documentation, and what all elements there are for us to use with...

Capture .Net web service method call output
I am debugging a .net web service client. Would someone please advise on how to view / capture the SOAP envelope XML generated for a web service method call by a .net web service client proxy? I am using PB 11.2 on windows XP. The .Net web service proxy was generated using the web service proxy wizzard from a WSDL supplied by a vendor of ours. When I view the method parameters in the proxy function they do not match the expected string data type for 2 enumerated elements; but I think they are converted internally. I am accessing the remote web service and receiving a general jav...

Page Method or Web Service call from Java script
Hello all, I need to call a server side method from Javascript (asp.net 2.0 ajax environment), My options are: call a Page Method or a Web Service, I implemented both of these for trial purpose on a page and found that a PostBack happens (i can see a Page refresh happening like in a normal post back). The call needs to fetch some values from a server side method without a post back, can somebody let me know what happens on the background when i make a Page method call or a web service call ? does a postBack actually happen ? You shouldn’t be getting a postback, if you ar...

Web resources about - Calling a Page Method Instead of a Web service method with javascript? - asp.net.networking-webservices

JavaScript Kit- Your comprehensive JavaScript, DHTML, CSS, and Ajax stop
Your comprehensive JavaScript, DHTML, CSS, and Ajax stop

Let's Code: Test-Driven Javascript by James Shore — Kickstarter
James Shore is raising funds for Let's Code: Test-Driven Javascript on Kickstarter! A screencast series focusing on rigorous, professional Javascript ...

Eloquent JavaScript: A Modern Introduction to Programming
... and pragmatics. I loved the tutorial-style game-like program development. This book rekindled my earliest joys of programming. Plus, JavaScript! ...

Lightbox (JavaScript) - Wikipedia, the free encyclopedia
On a Lightbox-enabled page, a user can click an image to have it magnified in a Lightbox window, which resizes itself according to the size of ...

Open Directory - Computers: Programming: Languages: JavaScript: Tools: Obfuscators
about dmoz - help Top : Computers : Programming : Languages : JavaScript : Tools : Obfuscators Tools for obfuscation/compression JavaScript code. ...

Facebook File-Transfer App Pipe Relaunches, Now Works Via JavaScript, WebRTC
... allowed Facebook users to send and receive files up to 1 gigabit in size. A new version of Pipe debuted Monday, and the app now works via JavaScript ...

Under the Hood: The JavaScript SDK - The use of polyfills - Facebook
Facebook Engineering hat eine Notiz mit dem Titel Under the Hood: The JavaScript SDK - The use of polyfills geschrieben. Du kannst den vollständigen ...

JavaScript SDK - Facebook-Entwickler
Overview The JavaScript SDK provides a rich set of client-side functionality for accessing Facebook...

Senior Front-End Developer (Javascript and AJAX)
Company: Sometrics Category: Software Development Location: Los Angeles, CA How to Apply: jobs@sometrics.com Description: We are looking for ...

Badass JavaScript (@badass_js) on Twitter
WebGLWorker is an open source library that allows using WebGL from Web Workers. Great work as always from @kripken . blog.mozilla.org/research/2014/… ...

Resources last updated: 12/25/2015 5:20:19 PM