Home All Groups Group Topic Archive Search About

ICallbackEventHandler

Author
4 Apr 2006 2:12 PM
SalamElias
I am implementing the ICallbackEventHandler interface, and one of its members
methods in a server control as follows :
public void RaiseCallbackEvent(string eventArgument)
    {
        if (eventArgument != "")
        {

            result += tmp1.ToString() + "), new Array(" + tmp2.ToString() + "));";
            return result;
        }
        else
        {
            return "showQueryDiv" + JS_suffixe + "('" + eventArgument + "', new
Array(), new Array());";
        }
        //throw new Exception("The method or operation is not implemented.");
    }

Yhe other method which I dont use as follows
public string GetCallbackResult()
    { }

When I compile I get the following erros

"Since 'contact_project.RaiseCallbackEvent(string)' returns void, a return
keyword must not be followed by an object expression"
and the second error
"contact_project.GetCallbackResult()': not all code paths return a value'


Thanks for your help

Author
4 Apr 2006 2:28 PM
SalamElias
I forgot to say that initially, I wanted my my raise event to return a
string, when I do
       public string RaiseCallbackEvent(string eventArgument)
                      {}
then compile, I get the following error

'contact_project' does not implement interface member
'System.Web.UI.ICallbackEventHandler.RaiseCallbackEvent(string)'.
'add_contact_project.RaiseCallbackEvent(string)' is either static, not
public, or has the wrong return type.       

Thanks again

Show quote
"SalamElias" wrote:

> I am implementing the ICallbackEventHandler interface, and one of its members
> methods in a server control as follows :
> public void RaiseCallbackEvent(string eventArgument)
>     {
>         if (eventArgument != "")
>         {
>            
>             result += tmp1.ToString() + "), new Array(" + tmp2.ToString() + "));";
>             return result;
>         }
>         else
>         {
>             return "showQueryDiv" + JS_suffixe + "('" + eventArgument + "', new
> Array(), new Array());";
>         }
>         //throw new Exception("The method or operation is not implemented.");
>     }
>
> Yhe other method which I dont use as follows
> public string GetCallbackResult()
>     { }
>
> When I compile I get the following erros
>
> "Since 'contact_project.RaiseCallbackEvent(string)' returns void, a return
> keyword must not be followed by an object expression"
> and the second error
> "contact_project.GetCallbackResult()': not all code paths return a value'
>
>
> Thanks for your help
>
Author
5 Apr 2006 6:25 AM
Steven Cheng[MSFT]
Hi Salam,

Thank you for posting.

Regarding on the ASP.NET 2.0 script call back issue, based on my research,
it seems a document issue. As for the ICallBackEventHandler interface, it
contains two member functions we need to implement:

#ICallbackEventHandler Methods
http://msdn2.microsoft.com/en-us/library/dcc3kkye.aspx

The "RaiseCallbackEvent" function does not have return value, so we can not
return any data in this function. If we need to return data to client-side,
we need to use the "GetCallbackResult" function. e.g:

_cbResult is a page member variable
=====================================
#region ICallbackEventHandler Members

    public string GetCallbackResult()
    {
        return _cbResult;

    }

    public void RaiseCallbackEvent(string eventArgument)
    {
        _cbResult = eventArgument + "__" +  DateTime.Now.ToLongTimeString();


    }

    #endregion
==============================

Hope this helps. And sorry for the inconvenience the document problem
brings you.

Regards,

Steven Cheng
Microsoft Online Community Support


==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.



Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

AddThis Social Bookmark Button