Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| 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
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 19th, 2010, 08:43 PM
Authorized User
 
Join Date: Jun 2010
Posts: 27
Thanks: 8
Thanked 0 Times in 0 Posts
Default Page 354 Chapter 10

He guys i have been busy with work and family life, hopefully back now untill i finish this book.
am having a problem in calling a web service from a client side code.

I am typing the exact code as in the book which is as follows:

<%@ Page Title="Web Services Demo" Language="C#" MasterPageFile="~/MasterPages/Frontend.master" AutoEventWireup="true" CodeFile="WebServices.aspx.cs" Inherits="Demos_WebServices" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" Runat="Server">
<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">

<Services>
<asp:ServiceReference Path="~/Demos/WebServices/NameService.asmx" />
</Services>

</asp:ScriptManagerProxy>

<input id="YourName" type="text" />
<input id="SayHello" type="button" value="Say Hello" />
<script type="text/javascript">
function HelloWorld()
{
var yourName = $get('YourName').value;
NameService.HelloWorld(yourName, HelloWorldCallback);
}

funciton HelloWorldCallback(result)
{
alert(result);
}

$addHandler($get('SayHello'), 'click', HelloWorld);
</script>

</asp:Content>


Things are working fine and browser comes with a services where it allows me to enter text(my name) but when i click Say Hello button nothing happens.
Left bottom cornor of the beowser says Done but with errors on page when i click the Say Hello button.

Any help is appriciated.

Tariq

Last edited by tariq; August 19th, 2010 at 08:54 PM..
Reply With Quote
  #2 (permalink)  
Old August 19th, 2010, 10:47 PM
Authorized User
Points: 350, Level: 6
Points: 350, Level: 6 Points: 350, Level: 6 Points: 350, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2010
Location: Eastern Michigan-Near Canada
Posts: 81
Thanks: 10
Thanked 3 Times in 2 Posts
Default

Hi Tariq,

I'm the night staff while Imar is catching 40 winks, (just kidding). I'm only in ch. 8 presently, but I have played with Web Services in vb and C# for a prescription database, so your question had my interest. I think I see your problem.

Quote:
funciton HelloWorldCallback(result)
I think just a syntax error 'function' misspelled.;-)
__________________
Bob
bdtcomp.com
http://lettersfromasoldier.com
Follow me on Twitter
“Success is not final, failure is not fatal: it is the courage to continue that counts.”~Winston Churchill
Reply With Quote
  #3 (permalink)  
Old August 20th, 2010, 02:05 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Quote:
I'm the night staff while Imar is catching 40 winks,


Tariq: did that fix it?

Cheers,

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!
Reply With Quote
  #4 (permalink)  
Old August 20th, 2010, 10:11 AM
Authorized User
 
Join Date: Jun 2010
Posts: 27
Thanks: 8
Thanked 0 Times in 0 Posts
Default Thanks for quick reply

I got it fixed accidentally Imar by changing the webservices path but not clear why it fixed the problem.

I changed the following line:


<asp:ServiceReference Path="~/Demos/WebServices/NameService.asmx" />

TO

<asp:ServiceReference Path="~/WebServices/NameService.asmx" />

Just removed the /Demos.

My concept is not clear can you please explain, i know that it has something to do with the nameservice path.

and thanks for the ractification btcomp
Tariq

Last edited by tariq; August 20th, 2010 at 10:25 AM..
Reply With Quote
  #5 (permalink)  
Old August 20th, 2010, 10:33 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

The service is located in the WebServices folder, which in turn is located in the root, not in the Demos folder. Your code tries to find a service file under the demos folder, which fails because it doesn't exist there.

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!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
tariq (August 21st, 2010)
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Chapter 10, Page 334 Saranjiv BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 July 20th, 2010 04:39 PM
Chapter 11 Page 354 skijor BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 6 August 9th, 2009 08:02 AM
Errata - Chapter 10, Page 377, C# RobC BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 5 October 3rd, 2006 02:26 AM
Errata - Chapter 10, Page 378, C# RobC BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 August 31st, 2006 09:56 AM
Ex 10, Chapter 5, page 253 Nick Y BOOK: Ivor Horton's Beginning Visual C++ 2005 1 June 16th, 2006 01:14 AM



All times are GMT -4. The time now is 12:15 PM.


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