Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Beginning ASP.NET 4 : in C# and VB
Password Reminder
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Display Modes
  #1 (permalink)  
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.)
Reply With Quote
  #2 (permalink)  
Old June 16th, 2011, 11:53 AM
Imar's Avatar
Wrox Author
Points: 71,384, Level: 100
Points: 71,384, Level: 100 Points: 71,384, Level: 100 Points: 71,384, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,980
Thanks: 79
Thanked 1,564 Times in 1,541 Posts

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 Spaanjaars
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!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
bakerboy (June 16th, 2011)

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 07:26 AM
What is the diff between ajax and callback method azymd777 ActionScript 0 February 28th, 2008 01:55 AM

All times are GMT -4. The time now is 08:38 PM.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.