Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Beginning ASP.NET 4 : in C# and VB
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 16th, 2011, 11:05 AM
Registered User
 
Join Date: Mar 2011
Posts: 3
Thanks: 2
Thanked 0 Times in 0 Posts
Default NameService.HelloWorld() success callback method (ch. 10, 356)

I'm wondering why the NameService.HelloWorld() method, which is defined with only one parameter ("yourName") doesn't throw an exception when it is called with two (or possibly three) parameters from the client-side Javascript HelloWorld() function (ch. 10, p. 356).

So the method's return "success callback" calls the second parameter named JS function and if there's an error the third parameter (if there is one) gets called. This is evidently special behavior caused by the preceding of the HelloWorld method with the [WebMethod] attribute. Yes?

I would have expected to see NameService.HelloWorld() as an overloaded method, accepting two or three parameters. Alternately, I would have expected the call to the service to have been done something like

<code>var result = NameService.HelloWorld(yourName);</code>

Then one would process "result", etc.

Please comment or elaborate. Thanks. (Great book, by the way.)
 
Old June 16th, 2011, 11:53 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

The client code (with 1, 2 or 3 parameters) doesn't call the web service directly. Instead, it calls a proxy class that is created on the fly. This proxy class then has the signature to handle the parameters, the success callbkach and the error callback.

Check out the HTML for the page and look at the <script /> elements. One of them is a reference to a dynamically generated JavaScript class with the JavaScript code required to interact with the Web Service on the server.

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
bakerboy (June 16th, 2011)





Similar Threads
Thread Thread Starter Forum Replies Last Post
NameService not defined error antonioplais BOOK: Beginning ASP.NET 4 : in C# and VB 1 June 5th, 2011 07:30 AM
Chapter 10 HelloWorld function ChuckASP BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 April 2nd, 2010 03:39 PM
Spring based Dao with callback Vs without callback kasipandian Spring 0 November 9th, 2009 08:26 AM
What is the diff between ajax and callback method azymd777 ActionScript 0 February 28th, 2008 02:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.