Yes, I'm getting a "Samples not defined" in the "Sample ASP.NET AJAX Client Application"
If you search on this error message, there are lots of people witht the same question and I've gone through their responses and verified that everything is correct.
I've verified that (what I can think of):
The namespace and the class name match the javascript callThe web service file "HelloWorldService.asmx" exists and is in the same directory location as AjaxScript.aspxMicrosoft.Web.Script.Services; is included in "HelloWorldService.asmx"Microsoft.Web.Extension is registered in AjaxScript.aspx
I looked at the source of the .aspx page and there is one line in particular that caught my attention:
<script src="HelloWorldService.asmx/jsdebug"type="text/javascript"></script>
The question is, where is this jsdebug file live? I suspect that this is the problem that the sample can't find it. I've assumed
it was in the \winnnt\microsoft.net\... folder but I couldn't find it.
Anyone have any ideas for fun?
Thanks, Tim
OS: Windows 2000 (5.0.2195: SP4)
Browser: Firefox 2.0/IE 6.0.2800.1106 (SP1)
Source Code for fun:
AjaxScript.aspx1<%@dotnet.itags.org. Page Language="C#" Title="ASP.NET AJAX Script Walkthrough" %>2<%@dotnet.itags.org. Register Assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="Microsoft.Web.UI" TagPrefix="asp" %>3456<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">78<html xmlns="http://www.w3.org/1999/xhtml">910 <head id="Head1" runat="server">11 <title />12 <style type="text/css">13 body { font: 11pt Trebuchet MS;14 font-color: #000000;15 padding-top: 72px;16 text-align: center }1718 .text { font: 8pt Trebuchet MS }19 </style>2021 </head>22 <body>23 <form id="Form1" runat="server">24 <asp:ScriptManager ID="ScriptManager" runat="server">25 <Services>26 <asp:ServiceReference path="~/HelloWorldService.asmx" />27 </Services>28 </asp:ScriptManager>29 30 <div>31 Search for32 <input id="SearchKey" type="text" />33 <input id="SearchButton" type="button" value="Search" onclick="DoSearch()" />34 </div>35 </form>36 <hr style="width: 300px" />37 <div>38 <span id="Results"></span>39 </div>40 <script type="text/javascript">4142 function DoSearch()43 {44debugger;45 var SrchElem = document.getElementById("SearchKey");46 Samples.AspNet.HelloWorldService.HelloWorld(SrchElem.value, OnRequestComplete);47 }4849 function OnRequestComplete(result)50 {51 var RsltElem = document.getElementById("Results");52 RsltElem.innerHTML = result;53 }5455 </script>56 </body>57</html>58HelloWorldService.asmx
1<%@dotnet.itags.org. WebService Language="C#" Class="Samples.AspNet.HelloWorldService" %>23using System;4using System.Web;5using System.Web.Services;6using System.Web.Services.Protocols;7using Microsoft.Web.Script.Services;89namespace Samples.AspNet10{1112 [WebService(Namespace="http://tempuri.org/")]13 [WebServiceBinding(ConformsTo=WsiProfiles.BasicProfile1_1)]14 [Microsoft.Web.Script.Services.ScriptService]15 public class HelloWorldService : System.Web.Services.WebService16 {17 public HelloWorldService()18 {1920//Uncomment the following line if using designed components21 //InitializeComponent();22 }2324 [WebMethod]25 public string HelloWorld(String query)26 {27 string inputString = Server.HtmlEncode(query);28 if (!String.IsNullOrEmpty(inputString))29 {30 return(String.Format("Hello, you queriedfor {0}. The" +31 "current timeis {1}", inputString, DateTime.Now));32 }33 else34 {35 return("The querystring wasnull or empty");36 }37 }38 }39}40
Hi Tim,
Just to clarify, the line<script src="HelloWorldService.asmx/jsdebug"type="text/javascript"></script> is added because of the <asp:ServiceReference> tag in your aspx code.
Make sure that you added your HelloWorldService.asmx where your tag is pointing to:"~/HelloWorldService.asmx". It should be right under your web app root.
You can check the proxy object typing /js or /jsdebug after your web service address (e.g. http://your_web_app_address/web_service_name.asmx/js).
Hope this helps,
MaĆra
No comments:
Post a Comment