Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Syntax error in HTML code and runtime error stating function is undefined

$
0
0

I'm trying to get a handle on ASP.NET web page coding in VisualStudio2008 (yep, I'm behind the times).  I used an MS Walk Through in MSDN titled "Walkthrough: Creating and Using AJAX-enabled ASP.NET Service".  When running the resulting web page, I kept getting an error "JavaScript runtime error:'OnClickGreetings' is undefined".  Finally, I gave up on that and found another, video based, tutorial titled "Creating and Using an AJAX-enabled Web Service in a Web Site".  I entered all of the code presented in that tutorial, but have at least 2 problems that I can't resolve.  Firstly, in VS, in the web page where I've embedded JavaScript, as instructed on the video, I have a small squiggly under the </script> closing tag.  When I hover over it, the tooltip says "Expecting more source characters".  I cannot for the life of me see what I' missing in the code between the <script> and </script> tags (I'm new to JavaScript, as well).

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %><!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 id="Head1" runat="server"><style type="text/css">
            body { font: 11pt Trebuchet MS;
                   color: #000000;
                   padding-top: 72px;
                   text-align: center; }
            .text { font: 8pt Trebuchet MD }</style><title>Simple Web Service</title><script type="text/javascript">

    function OnGreetingsClick()
    {
        Samples.Aspnet.HelloWorld.Greetings(
            $get("NameTextBox").value,
            OnGreetingsComplete);
    {

    function OnGreetingsComplete(result)
    {
        var elem = $get("Results");
        elem.innerHTML = result;
    }</script></head><body><form id="form1" runat="server"><div><asp:ScriptManager runat="server"><Services><asp:ServiceReference Path="http://localhost/WT_HelloWorldWebService/HelloWorld.asmx" /></Services></asp:ScriptManager><h2>Simple Web Service Client</h2><p>Calling a simple service that shows a greeting
     and the server date and time</p><table><tr><td>Name:</td><td><input type="text"
                id="NameTextBox" /></td></tr><tr><td>&nbsp;</td><td><button id="GreetingsButton"
                onclick="OnGreetingsClick()">Greetings</button></td></tr></table></div><hr /><div><span id="Results"></span></div></form></body></html>


Secondly, if I ignore the  VS error, and try and run the page, it renders fine, but when I try to test the javascript function behind the Greetings button, I get an error similar to the one I got with the initial MS Walk Through, which is "Error: 'OnGreetingsClick' is undefined.  I'm hoping that this error may be a result of the syntax error, but I sure don't know what the syntax error is telling me.  Thanks for any light you can shed on this.


Viewing all articles
Browse latest Browse all 5678

Latest Images

Trending Articles



Latest Images