Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 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 March 10th, 2008, 12:06 PM
Registered User
 
Join Date: Aug 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Partial page update with Script call backs

Plz refer to page 344-345 of the book.

My aspx code is as follows:
************
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Java_Callback.aspx.cs"
        Inherits="Java_Callback" %>


<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
    <script type="text/javascript" >
        function ShowResult(result, context)
        {
            alert(result);
        }

    </script>

</head>
<body>
    <form id="form1" runat="server">

        <asp:TextBox ID="txtValue" runat="server" />
        <input id="btnSubmit" runat="server" type="button" value="Calc" />

    </form>
</body>
</html>
********************
the corresponding code behind file is as per below:
***********
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Java_Callback : System.Web.UI.Page, ICallbackEventHandler
{
    string callbackResult = "";

    protected void Page_Load(object sender, EventArgs e)
    {
        string callbackRef = this.ClientScript.GetCallbackEventReference(this,
            "window.document.getElementByID('txtValue').value" , "ShowResult", null);
        btnSubmit.Attributes.Add("onclick", callbackRef);
    }

    public string GetCallbackResult()
    {
        return callbackResult;
    }

    public void RaiseCallbackEvent(string eventArgument)
    {
        callbackResult = (int.Parse(eventArgument) * 2).ToString();
    }
}
***************

When I view the aspx page in browser, type a number in textbox and click on the button, I get error "Microsoft JScript runtime error: Object doesn't support this property or method", with highlighted line ( in VS) "onclick="WebForm_DoCallback('__Page',window.docum ent.getElementByID('txtValue').value,ShowResult,nu ll,null,false)"

Grateful if anyone could please point me to source of the error and how to rectify.

Big Thanks !!



 
Old March 12th, 2008, 11:42 PM
Authorized User
 
Join Date: Mar 2008
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I know this might be javascript being picky, but make sure you lowercase the letter "d" in "getElementById". This might be the problem. Good luck!

 
Old March 14th, 2008, 05:38 AM
Registered User
 
Join Date: Aug 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by slatergator
 I know this might be javascript being picky, but make sure you lowercase the letter "d" in "getElementById". This might be the problem. Good luck!

It sure did resolve the problem !!!

thank you slatergator !!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Call and/or start C# WinApp from script spif2001 C# 2005 0 September 20th, 2007 02:38 AM
Client Call Backs DotNetJunk ASP.NET 1.0 and 1.1 Professional 1 December 5th, 2006 03:16 AM
Client Call Backs DotNetJunk ASP.NET 2.0 Professional 0 December 4th, 2006 06:24 PM
How do I call Excel script from Access? vmerc Access VBA 8 August 16th, 2005 01:28 PM
Call and run CGI script from a PHP script ... how? dbruins BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 June 10th, 2003 03:09 PM





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