Wrox Programmer Forums
|
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 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..
 
Old August 19th, 2010, 10:47 PM
Authorized User
 
Join Date: Jul 2010
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
 
Old August 20th, 2010, 02:05 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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!
 
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..
 
Old August 20th, 2010, 10:33 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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!
The Following User Says Thank You to Imar For This Useful Post:
tariq (August 21st, 2010)





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





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