Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 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 February 25th, 2009, 12:49 PM
Friend of Wrox
 
Join Date: Feb 2009
Posts: 194
Thanks: 5
Thanked 3 Times in 3 Posts
Default Web service not displaying an alert

Ok I am reading through the AJAX chapter now and have got to the bit about web services.

My understanding of a web service is that is making a method publicly available to call upon aslong as it is referenced by the particular page that wants to use it so it knows where to look. Is this the basic concept of it?

Secondly mine isn't working for some reason

The web service itself works and the JavaScript is correct (copied it from the source file to be sure) and I have uncommented the line allowing the web service to be called from script by ASP.NET AJAX in the app data file.

I am really confused as to why it isn't working. It builds and runs fine it just doesn't display the alert after clicking the button. JavaScript is enabled in my browser do you have any idea what it might be?
 
Old February 25th, 2009, 01:06 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Yes, that's pretty much the idea. For example, consider this service:

http://imar.spaanjaars.com/WebServic...icContent.asmx

It allows you, from an application, to retrieve content like my latest articles and the track I am currently playing in WinAmp (quite useless, but fun nonetheless. Take a look here for more info: http://imar.spaanjaars.com/QuickDocID.aspx?QUICKDOC=277).

Anyway, back to your service: what happens when you right-click the asmx file and choose View in browser? Does it show up?

Did you add the service reference to the ScriptManager like this:

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

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:
Will (February 25th, 2009)
 
Old February 25th, 2009, 03:10 PM
Friend of Wrox
 
Join Date: Feb 2009
Posts: 194
Thanks: 5
Thanked 3 Times in 3 Posts
Default

Yup the web service itself works, the service reference is there, the javascript is correct and enabled in my browser I really can't see why it isn't working.
 
Old February 25th, 2009, 03:39 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Can you send me the zipped source for the site so I can take a look?

You can send me a message through my profile page to which I'll reply so you know my e-mail address.

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 February 25th, 2009, 05:32 PM
Friend of Wrox
 
Join Date: Feb 2009
Posts: 194
Thanks: 5
Thanked 3 Times in 3 Posts
Default

I wish I could lol but I can't seem to find a send message to you on your profile page unless I am being really blind..
 
Old February 25th, 2009, 06:14 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Will,

Maybe that option isn't available to new users of this forum?

You can also go to http://imar.spaanjaars.com and click the Contact tab. It won't be until tomorrow that I have time to look at it though; it's almost midnight here....

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 February 25th, 2009, 06:24 PM
Friend of Wrox
 
Join Date: Feb 2009
Posts: 194
Thanks: 5
Thanked 3 Times in 3 Posts
Default

fair enough. I have kept plodding away trying to figure it out and its bugging me because it is probably going to be really simple. Hope you can find something when you have time.

I have sent you an email.
 
Old February 26th, 2009, 05:19 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 Will,

Thanks for the source. I looked at the WebServices page and found this:
Code:
 
<input id="btnSayHello" type="submit" value="Say hello" />
The type is set to submit which causes a postback to the server. If the page is processed fast enough, while the Web Service takes some time, it may be too late for the alert to appear (although it worked for me the first time I tried it). Try changing it to:

Code:
 
<input id="btnSayHello" type="button" value="Say hello" />
and see if that helps....

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 February 26th, 2009, 05:30 AM
Friend of Wrox
 
Join Date: Feb 2009
Posts: 194
Thanks: 5
Thanked 3 Times in 3 Posts
Default

And the whole point of the javascript is that it occurs on the client side right?

It works fine now.

Thank you.
 
Old February 26th, 2009, 05:34 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Yes, exactly. You could easily create a web form that accepts the user's name and creates a message. But the idea of this example is that you can access server side functionality without a postback, making responses seem quicker and smoother...

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:
Will (February 26th, 2009)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Displaying Web page dilipv General .NET 0 March 5th, 2008 05:39 AM
Web Service Consuming another web service CraigWhitfield EJB 0 January 10th, 2008 08:38 AM
Error to Add Web Reference from a Web service jdjbarrios ASP.NET 2.0 Professional 0 July 18th, 2006 02:58 PM
Service Oriented Web Service aldwinenriquez .NET Web Services 2 September 15th, 2005 03:25 AM
Displaying CustomValidator Error Messages in alert farhan_iac General .NET 0 August 20th, 2004 12:37 AM





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