p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9
This is the forum to discuss the Wrox book Professional ASP.NET 2.0 Special Edition by Bill Evjen, Scott Hanselman, Devin Rader, Farhan Muhammad, Srinivasa Sivakumar; ISBN: 9780470041789

Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 4th, 2006, 12:12 AM
Registered User
 
Join Date: Jun 2006
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default charpter 4 callback feature

does anyone know how to use this feature?

i have followed the listing 4-14, and modified the codes based on the changes to ICallbackEventHandler class in asp.net 2.0 final release, but i got "UseCallback" is not defined when i access the aspx page. it complains the UseCallback() javascript function, which is created in the code-behind, is not defined. do i need to setup anything to enable this callback feature in 2.0? please help.



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old July 2nd, 2006, 12:44 PM
Registered User
 
Join Date: Jul 2006
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I believe 'UseCallback' is an arbitrary name. You do have to define it yourself. On page 124, the book seems to define the function in this chunk of code:

Code:
string cbReference = Page.ClientScript.GetCallbackEventReference(this, "arg", "GetRandomNumberFromServer", "context");
string cbScript = "function UseCallback(arg, context)" + 
  "{" + cbReference + ";" + "}";

Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "UseCallback", cbScript, true);
And remember JavaScript is case sensitive; "UseCallback" and "UseCallBack" are different.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old March 1st, 2007, 11:53 PM
Authorized User
 
Join Date: Feb 2006
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm having the same problem with this one using the C# code.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old March 3rd, 2007, 10:47 PM
Authorized User
Points: 142, Level: 2
Points: 142, Level: 2 Points: 142, Level: 2 Points: 142, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2006
Location: , , .
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi does your code works at all?
or you simply want to know more about the CallBack feature?
This one works fine.
In a case you still need a working one, copy paste it to your project.

//---------------------------------------------------------------------------

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" 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 runat="server" id ="Head1">
    <title>Listing 4-14 CallBackPage</title>


    <script type ="text/javascript">

    function GetNumber()
    {
      UseCallback(); // Don't Make a Typo here :)
    }

    function GetRandomNumberFromServer(TextBox1, context)
    {
      document.forms[0].TextBox1.value = TextBox1;
    }

    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
          <input id ="Button1" type ="button" value ="Get Random Number" onclick ="GetNumber()" />
          <br />
          <br />
          <asp:TextBox ID ="TextBox1" runat ="server"></asp:TextBox>
    </div>
    </form>
</body>
</html>

================================================== ===========================
c# Code behind

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 _Default : System.Web.UI.Page, //Dont't forget the Comma here,
   System.Web.UI.ICallbackEventHandler
{
    private string _callbackResult = null;

    protected void Page_Load(object sender, EventArgs e)
    {
        string cbReference = Page.ClientScript.GetCallbackEventReference(this,
           "arg", "GetRandomNumberFromServer", "context");
        string cbScript = "function UseCallback(arg, context)" +
           "{" + cbReference + ";" + "}";

        Page.ClientScript.RegisterClientScriptBlock(this.G etType(),
           "UseCallback", cbScript, true);
    }

    public void RaiseCallbackEvent(string eventArg)
    {
        Random rnd = new Random();
        _callbackResult = rnd.Next().ToString();
    }

    public string GetCallbackResult()
    {
        return _callbackResult;
    }
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #5 (permalink)  
Old July 10th, 2008, 06:16 PM
Registered User
 
Join Date: Jul 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the source code but that did not work without fully qualifying the two callback methods with ICallbackEventHandler.



   string ICallbackEventHandler.GetCallbackResult()
    {
        //throw new Exception("The method or operation is not implemented.");
        return _callbackResult;
    }

    void ICallbackEventHandler.RaiseCallbackEvent(string eventArgument)
    {
        Random rnd = new Random();
        _callbackResult = rnd.Next().ToString();
    }

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom controls and callback PatrickRuzand BOOK: Professional ASP.NET 2.0 AJAX ISBN: 978-0-470-10962-5 0 August 28th, 2007 11:20 AM
callback implementation aranjan ASP.NET 2.0 Basics 1 August 20th, 2007 10:46 PM
Callback in 3 DropDownLists Paula222 ASP.NET 2.0 Professional 3 December 13th, 2006 08:53 AM
Worldpay Callback Script Countach1976 PHP Databases 3 January 1st, 2005 10:36 AM
Remoting.Callback sample mikhail BOOK: Professional C#, 2nd and 3rd Editions 0 July 11th, 2003 05:02 PM



All times are GMT -4. The time now is 03:34 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc