Callback

Answered (Verified) This post has 1 verified answer and 5 replies

Not Ranked
Posts: 8
mnapierski Posted: Wed Jan 20, 2010 @ 9:36 AM
Hello,
how can i raise on server-side an OnCallbackError event? Or how can i pass values back to client after calling the callback?

with best regards
Meik Napierski

Answered (Verified) Verified Answer

Top 10 Contributor
Posts: 6,149
Answered (Verified) stephen Posted: Wed Jan 20, 2010 @ 11:21 AM
Verified by stephen

You can raise an error by throwing one- here's a quick example:

 

<script>
        function myError(sender, args) {
            alert("error! " + args.get_message());
        }
    </script>

<input type="button" value="do callback" onclick="myCallback.callback();" />
        <ComponentArt:CallBack runat="server" OnCallback="myCallback_Callback" ID="myCallback">
           <Content>
                <asp:TextBox runat="server" ID="txt"></asp:TextBox>
           </Content>
           <ClientEvents>
            <CallbackError EventHandler="myError" />
           </ClientEvents>
        </ComponentArt:CallBack>
  protected void myCallback_Callback(object sender, ComponentArt.Web.UI.CallBackEventArgs e)
    {
           throw new NotImplementedException("this isn't done yet");
    }
I hope this helps.

Stephen Hatcher, Developer Support Manager

All Replies

Top 10 Contributor
Posts: 6,149
Answered (Verified) stephen Posted: Wed Jan 20, 2010 @ 11:21 AM
Verified by stephen

You can raise an error by throwing one- here's a quick example:

 

<script>
        function myError(sender, args) {
            alert("error! " + args.get_message());
        }
    </script>

<input type="button" value="do callback" onclick="myCallback.callback();" />
        <ComponentArt:CallBack runat="server" OnCallback="myCallback_Callback" ID="myCallback">
           <Content>
                <asp:TextBox runat="server" ID="txt"></asp:TextBox>
           </Content>
           <ClientEvents>
            <CallbackError EventHandler="myError" />
           </ClientEvents>
        </ComponentArt:CallBack>
  protected void myCallback_Callback(object sender, ComponentArt.Web.UI.CallBackEventArgs e)
    {
           throw new NotImplementedException("this isn't done yet");
    }
I hope this helps.

Stephen Hatcher, Developer Support Manager
Top 200 Contributor
Posts: 33
clctechnology Posted: Tue Jan 17, 2012 @ 1:19 PM
this works, but after my custom message followed by another message 'the data could not be loaded'.

Is there a way to avoid this?
Top 10 Contributor
Posts: 6,149
stephen Posted: Wed Jan 18, 2012 @ 6:54 AM

In what browser? I just tested the exact code above in FireFox, Chrome and IE and they all had the same result- an alert that says "this isn't done yet" and nothing else. You'd generally get the second alert if there actually was an error loading data- in other words, the error isn't handled. Is your code different then mine? If so, how? 

Stephen Hatcher, Developer Support Manager
Top 200 Contributor
Posts: 33
clctechnology Posted: Wed Jan 18, 2012 @ 12:32 PM
I see the issue. The callback where I want to set the custom message also has a CallbackComplete event. Within the callback complete javascript method, I try to call additional callbacks and those fail to load properly. It seems the throwing of an exception ceases the processing of the page which in my case is not going to work. I have worked around this by setting text on a label on the UI instead of using the CA error dialog. Thanks.
Top 10 Contributor
Posts: 6,149
stephen Posted: Thu Jan 19, 2012 @ 6:26 AM

Ah, great- glad to hear you've sorted it! 

Stephen Hatcher, Developer Support Manager
Page 1 of 1 (6 items)