Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 10th, 2008, 12:06 PM
Registered User
 
Join Date: Aug 2007
Location: , , .
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 !!



  #2 (permalink)  
Old March 12th, 2008, 11:42 PM
Authorized User
 
Join Date: Mar 2008
Location: , , .
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!

  #3 (permalink)  
Old March 14th, 2008, 05:38 AM
Registered User
 
Join Date: Aug 2007
Location: , , .
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 !!

 


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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 01:02 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.