473,586 Members | 2,776 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

error using ICallbackEventH andler in ASP.Net 2.0

When trying to compile (using Visual Web Developer 2005 Express Beta;
frameworkv2.0.5 0215 ) the source code below I get errors (listed below due to
the use of ICallBackEventH andler. Ultimately I want to use a callback from
the client side to update webcontrols based on user input without using
postback.

I am seeking a way to stop the compile errors.

using System;
using System.Data;
using System.Configur ation;
using System.Web;
using System.Web.Secu rity;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.W ebControls.WebP arts;
using System.Web.UI.H tmlControls;

public partial class _Default : ICallbackEventH andler
{
protected void Page_Load(objec t sender, EventArgs e)
{

}

public string RaiseCallbackEv ent(string eventArgument) { }
}

I get these errors
1. 'ASP.Index_aspx .FrameworkIniti alize()': no suitable method found to
override c:\WINNT\Micros oft.NET\Framewo rk\v2.0.50215\T emporary ASP.NET
Files\callback\ 02ec0c94\71251b 27\tvquf1zy.0.c s

2. 'ASP.Index_aspx .GetTypeHashCod e()': no suitable method found to
override c:\WINNT\Micros oft.NET\Framewo rk\v2.0.50215\T emporary ASP.NET
Files\callback\ 02ec0c94\71251b 27\tvquf1zy.0.c s

I added the code
protected virtual void FrameworkInitia lize()
{

}

protected override void GetTypeHashCode ()
{

}

but then I get an error about the access level of GetTypeHashCode
Error 1 'ASP.Default_as px.GetTypeHashC ode()': cannot change access modifiers
when overriding 'protected' inherited member
'_Default.GetTy peHashCode()' c:\WINNT\Micros oft.NET\Framewo rk\v2.0.50215\T emporary ASP.NET Files\callback\ 02ec0c94\71251b 27\zqawgoe7.0.c s

Nov 22 '05 #1
1 5762
Okay, I think I have this one figured out. It seems that some things changed
in the 2.0 DotNet framework with Beta 2. All of the "Client Callback"
samples I found on the web didn't seem to work. As a starting point, I ended
up using a bit of the code found in the article found here:
http://www.devx.com/dotnet/Article/20239/0/page/2. After trying a lot of
different things, I boiled it down to a simple example that I was able to
get to work. I'm using Visual Studio 2005 (Beta 2) with code-behind pages.
Here is the text from my "Test.aspx" page:

<%@ Page Language="C#" AutoEventWireup ="true" CodeFile="Test. aspx.cs"
Inherits="Test" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Client Callback Test</title>
<script type="text/javascript">
function DoSomething(){
TheText =
document.getEle mentById("TextB ox1").getAttrib ute("value");
CallServer(TheT ext, "'DoSomethi ng' was called.");
}

function CallBackHandler (result,context )
{
document.getEle mentById("TextB ox2").innerTex t = "CallBackHandle r
Invoked. \nResult: " + result + "\nContext: " + context;

}
function ErrorCallBack(r esult,context)
{
alert("Error occurred : " + result);
}

</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="Button1" type="button" value="button"
onclick="DoSome thing()" />
<asp:TextBox ID="TextBox1" runat="server"> </asp:TextBox><br /><br />
<asp:TextBox ID="TextBox2" runat="server" TextMode="Multi Line"
Height="140px" Width="312px"></asp:TextBox>
</div>
</form>
</body>
</html>

Here's the text from my "Test.aspx. cs" file:

using System;
using System.Data;
using System.Configur ation;
using System.Collecti ons;
using System.Web;
using System.Web.Secu rity;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.W ebControls.WebP arts;
using System.Web.UI.H tmlControls;

public partial class Test : System.Web.UI.P age, ICallbackEventH andler
{
protected void Page_Load(objec t sender, EventArgs e)
{

if (!IsPostBack)
{
string bScript = ClientScript.Ge tCallbackEventR eference(this,
"myArg", "CallBackHandle r", "myContext" , "ErrorCallBack" , true);
//create the Javascriptfunct ion that makes the actual server
call.
string sb = "function CallServer(myAr g,myContext)\n{ \n" +
bScript + "\n}";
//Register the clientscript.
Page.ClientScri pt.RegisterClie ntScriptBlock(t his.GetType(),
"CallServer ", sb.ToString(), true);
}

}
public String RaiseCallbackEv ent(String eventArgument)
{
int myInt = int.Parse(event Argument.Trim() ) * 2;
return "The new value is " + myInt.ToString( );
}
}

The first important thing to note is that the partial class inherits the
Web.UI.Page class AND implements the ICallbackEventH andler interface. I
think this takes care of the "...no suitable interface found..." type
errors. Then, it looks like the "GetCallbackEve ntReference" method has been
rolled into the ClientScript object, which is the "Page" implementation of
the "ClientScriptMa nager" class, so it must be called as such.

The basic explanation of how my example works is: When the user clicks on
"Button1," the javascript function "DoSomethin g" is called. The
"DoSomethin g" function grabs the value from "TextBox1" and passes it off in
the call to the server, by making a call to the "CallServer " function. The
actual javascript function "CallServer " will have already been created
during the initial Page_Load execution and inserted into the aspx page via
the "RegisterClient ScriptBlock" method (you'll note there is also some
additional auto-generated code created at this time that is inserted into
the client aspx page that is needed to do the callback). So, that
"CallServer " function on the client invokes the "RaiseCallbackE vent" method
on the server, which attempts to convert the string into an integer,
multiply it by two, and return the value as part of a new string. If the
initial value is an integer, it does the calculation and passes back the new
string back to the client, invoking the execution of the JavaScript
"CallBackHandle r" function, which displays the various lines of text, part
of which came from the server. If the initial value isn't an integer, the
server throws an exception and the client JavaScript function
"ErrorCallB ack" is executed instead. There is only one string that gets
passed from the client to the server (as a parameter in the
"RaiseCallbackE vent" method), and the second "Context" parameter is
something that stays unchanged (by the server) on the client side, which can
be useful to determine where in the code on the client side the callback was
made.

Well, anyway, hope this is helpful. I know I was glad to finally get this
much-celebrated, but as of yet, not terribly well-documented new feature to
work.

Troy

"Mike" <si***@newsgrou ps.nospam> wrote in message
news:98******** *************** ***********@mic rosoft.com...
Nov 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1398
by: Mike | last post by:
When trying to compile in Visual Web Developer 2005 express beta (framework version )the source code using System; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class _Default : ICallbackEventHandler
1
567
by: Mike | last post by:
When trying to compile (using Visual Web Developer 2005 Express Beta; frameworkv2.0.50215 ) the source code below I get errors (listed below due to the use of ICallBackEventHandler. Ultimately I want to use a callback from the client side to update webcontrols based on user input without using postback. I am seeking a way to stop the...
1
1147
by: JimGreen | last post by:
I recently installed Release Candidate of VS2005 and I am not sure what the hell is the problem but ICallbackEventHandler definition on my machine looks like this: public interface ICallbackEventHandler { string GetCallbackResult(); void RaiseCallbackEvent(string eventArgument); }
2
3401
by: Anand | last post by:
Hi Season Greetings, I'm trying to implement client call backs in my page. i'm using user controls (composite controls) and these are placed in my master page. I'm implementing ICallbackEventHandler and ICallbackContainer interfaces in my user control class to generate the callback, and i palced the respective javascript function in...
2
2502
by: Alani | last post by:
Hello All, I'm a new ASP.NET programmer and I want to create a custom control consist of two properties (Number1) and (Number2) and both of them are integers and default value = 0, now I'm using callback technique so I can change those two proprties via ChangeNumber1 and ChangeNumber2 functions. what happens is that when I change the...
3
7404
by: Martin | last post by:
Hi, I have an aspx page with two dropdownlist controls. I update the options in the second ddl based on selection made in the first. I do this with the ICallbackEventHandler interface, as per "Implementing Client Callbacks Without Postbacks in ASP.NET Web Pages" (http://msdn2.microsoft.com/en-us/library/ms178208.aspx) This works.
0
968
by: Slim | last post by:
I made a page today that uses ICallbackEventHandler. I got to work, but with problems. 1. it is slow, it does not seem any faster than reloading the page. 2. the first time I fire the event it works fine, I get a result back from the server, but if I try to fire it again too soon it does not work. Q. am I supposed to be able to rebuild...
1
2010
by: Ben Schumacher | last post by:
I have a page that implements ICallbackEventHandler. I'm trying to accomplish auto saving a page everytime the user navigates away from the page. To initialize the callback, I fire the onunload event on the window as can be seen below. <script type="text/javascript"> window.onunload = Save; function Save()
0
1441
by: =?Utf-8?B?TG93bGFuZGVy?= | last post by:
Hello, I've built a web application that uses client script callbacks. It is used on a large network with a large variety of user OSes and IE versions. It was tested on IE 6 on different setups and IE 5.5 to a lesser degree without problems. I know of a least one user who gets an error in WebResource.axd when using the application. The...
0
775
by: dcrawford | last post by:
Hi All I have an Icallbackeventhandler working which updates a multiselect list box by removing the current items and then rebuilding the list with either terminated or active employees. The box populates exactly as expected, however when I submit the list the aspx file doesn't see the changed list it is still seeing the original. It also...
0
8200
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8215
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1448
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.