This is a migrated thread and some comments may be shown as answers.

catch ajaxRequestWithTarget server-side

4 Answers 164 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Bert
Top achievements
Rank 1
Bert asked on 30 Jul 2008, 12:24 PM
Hi,

Is it possible to catch the ajaxRequestWithTarget (client side) in an eventhandler on the server side?

When I try to catch the normal ajaxRequest in an eventhandler everything works fine but when I use the ajaxRequestWithTarget function in my client code, I can't catch it. Do I have to do anything else or am I forgetting something.

Thanks

Bert

4 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 30 Jul 2008, 12:31 PM
Hello Bert,

Typically this will raise the post back event of an IPostBackEventHandler exactly in the same way as with __doPostBack(). For a button for example ajaxRequestWithTarget() will raise button Click event.

You can catch globally at page level all post back events if you override RaisePostBackEvent() method:

    protected override void RaisePostBackEvent(IPostBackEventHandler sourceControl, string eventArgument)
    {
        base.RaisePostBackEvent(sourceControl, eventArgument);
    }

sourceControl argument is the Control which will raise post back event.

Greetings,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Bert
Top achievements
Rank 1
answered on 30 Jul 2008, 12:38 PM
Thanks for the fast reply.

There was just 1 thing that forgot to mention. It's not a page where I want to catch the event. It's in a usercontrol. In hereI think that I can't override the RaisepostBackEvent.

Is there a way to do this?

thanks

Bert
0
Accepted
Sebastian
Telerik team
answered on 30 Jul 2008, 12:45 PM
Hello Bert,

enerally UserControl does not implement IPostBackEventHandler. That is why, to achieve your goal you need to implement the following interface when needed. Here is the bare bone logic:

public class WebUserControl1 : System.Web.UI.UserControl, IPostBackEventHandler  
  {  
     public void RaisePostBackEvent(string eventArgument)  
     {  
     }  

Public Class WebUserControl1  
    Inherits System.Web.UI.UserControl  
    Implements IPostBackEventHandler  
 
    Public Sub RaisePostBackEvent(ByVal eventArgument As StringImplements System.Web.UI.IPostBackEventHandler.RaisePostBackEvent  
 
    End Sub 
End Class 

Best regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Bert
Top achievements
Rank 1
answered on 30 Jul 2008, 01:08 PM
ok thanks for all
Tags
Ajax
Asked by
Bert
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Bert
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or