p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > ASP.NET and ASP > ASP.NET 3.5 > BOOK: Professional ASP.NET 3.5 AJAX ISBN: 9780470392171
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional ASP.NET 3.5 AJAX ISBN: 9780470392171
This is the forum to discuss the Wrox book Professional ASP.NET 3.5 AJAX by Bill Evjen, Matt Gibbs, Dan Wahlin ; ISBN: 9780470392171

Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET 3.5 AJAX ISBN: 9780470392171 section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 23rd, 2009, 07:21 AM
Authorized User
Points: 221, Level: 4
Points: 221, Level: 4 Points: 221, Level: 4 Points: 221, Level: 4
Activity: 2%
Activity: 2% Activity: 2% Activity: 2%
 
Join Date: Apr 2009
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 1 pg 14 Error on page at runtime

Hello all,

I have completed the example on page 14 and 15 and when trying to run once I press the button all I get is an error in internet explorer saying "error on page"

My asmx.cs file looks like this
it is located at aspajax3point5\App_Code\listing1-1.cs

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
/// <summary>
/// Summary description for listing1_1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
// [System.Web.Script.Services.ScriptService]
public class listing1_1 : System.Web.Services.WebService {
public listing1_1 () {
//Uncomment the following line if using designed components 
//InitializeComponent(); 
}
[WebMethod]
public string HelloWorld() {
return "Hello ajax World";
}

}
the asmx file is located in a differenet path
aspajax3point4\listing1-1.asmx

My html file looks like this

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Basic AJAX Page</title>
<script type="text/javascript" language="javascript">
function InitiationFunction()
{
var xmlHttp;
try
{
xmlHttp = new XMLHttpRequest();
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
xmlHttp.onreadystatechange = function()
{
if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
{
response = xmlHttp.responseXML;
document.forms[0].statement.value = 
response.getElementsByTagName("string") [0].firstChild.nodevalue;
}
}
xmlHttp.open("GET","~/listing1-1.asmx/HelloWorld?",true);
xmlHttp.send(null);
</script>
</head>
<body>
<form>
<div>
Statement from server:
<input type="text" name="statement" />
<br />
<br />
<input id="Button1" type="button" value="Button"
onclick="InitiationFunction()" />
</div>
</form>
</body>
</html>
Is the
xmlHttp.open("GET","~/listing1-1.asmx/HelloWorld?",true); the correct reference to the asmx file or should this reference the code?

Is the "~" the correct path?

The error in internet explorer says that the error occurs on Line 56 which in the html file
says the following

onclick="InitiationFunction()" />

Does this mean that it can't find InitiationFunction or that there is a problem in the InitiationFunction code?

Any help would be most appreciated.

Cheers

Tomche
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 14 (Page 483) CSS Declaration jsymons BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 11 September 18th, 2009 08:14 AM
Chapter 14 page 491 Will BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 4 April 25th, 2009 05:52 AM
Chapter 14 - Warnings on page 484 havardoj BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 5 February 22nd, 2009 04:31 PM
Chapter 14 page 580 Problems with example john_reeve41 BOOK: Beginning ASP 3.0 3 February 4th, 2004 10:21 AM
Chapter 14 Page 780-781 JonR BOOK: Professional C#, 2nd and 3rd Editions 0 August 11th, 2003 09:27 PM



All times are GMT -4. The time now is 03:20 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc