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 February 26th, 2011, 05:02 PM
Registered User
 
Join Date: Feb 2011
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
Default Chapter 10 Page 359 Try It Out

Hello!

I am receiving the scripting error message when I open the WebServices.aspx.

Error: Sys.ArgumentNullException: Value cannot be null.
Parameter name: element

Code:
<%@ Page Title="Web Services Demo" Language="VB" MasterPageFile="~/Masterpages/FrontEnd.master" AutoEventWireup="false" CodeFile="WebServices.aspx.vb" 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="~/WebServices/NameService.asmx" />
    </Services>    
</asp:ScriptManagerProxy>
    <input id="Text1" type="text" />
    <input id="Button1" type="button" value="Say Hello" />
    <input id="SayHelloPageMethod" type="button" value="Say Hello with a Page Method"/>
    <script type="text/javascript">
        function HelloWorld()
        {
            var yourName = $get('YourName').value;
            NameService.HelloWorld(yourName, HelloWorldCallback);
        }
        function HelloWordPageMethod()
        {
            var yourname = $get('YourName').value;
            PageMethods.HelloWorld(yourname, HelloWorldCallback);
        }
        function HelloWorldCallback(result)
        {
            alert(result);
        }

        $addHandler($get('SayHello'), 'click', HelloWorld);

        $addHandler($get('SayHelloPageMethod'), 'click', HelloWordPageMethod);

       
    </script>
</asp:Content>
WebServices.aspx.vb
Code:
Imports System.Web.Services
Partial Class Demos_WebServices
    Inherits BasePage
    <WebMethod()>
    Public Shared Function HelloWorld(ByVal yourname As String) As String
        Return String.Format("Hello {0}", yourname)
    End Function
End Class
The Nameservice.vb worked perfectly, but this error, even when I ask it to continue, is stopping the code.
Thanks!
 
Old March 4th, 2011, 03:50 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 there,

A bit late response as I was at the MVP Summit in Redmond the past week.

I think the problem is that you forgot to rename the button's ID from Button1 to SayHello,

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!
 
Old March 4th, 2011, 10:03 AM
Registered User
 
Join Date: Feb 2011
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
Default Chapter 10 Page 359 Try It Out

Thank you so much! What a silly mistake. Also, after I finished that, I found that I wasn't using yourname case sensitive; so the next error I got was that 'yourname' wasn't defined. Got that fixed and it's working fine.

Sure appreciate your help.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 10, Page 359 - error? demac3 BOOK: Beginning ASP.NET 4 : in C# and VB 5 November 6th, 2010 03:57 AM
Page 354 Chapter 10 tariq BOOK: Beginning ASP.NET 4 : in C# and VB 4 August 20th, 2010 10:33 AM
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
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.