One-way ajax

4 posts, 0 answers
  1. Valera
    Valera avatar
    2 posts
    Member since:
    Jul 2011

    Posted 01 Nov 2011 Link to this post


    I would like to know if it is possible to create "one-way" ajax request?

    Example of the scenario:
    By clicking a button, web page send an email... there is no GUI changes on the page.

    Currently I use RadAjaxManager with following syntax:
    manager.AjaxSettings.AddAjaxSetting(btnSendEmail, btnSendEmail);

    As you can see, in order to AddAjaxSetting, I need to specify AjaxTrigger control and AjaxifiedCntrol (in this case they are the same controls).

    But I was wondering if I could only specify AjaxTrigger control, without specifying a control that is being updated?

    I'm looking to improve page responsiveness to "one-way" ajax requests...
  2. Marin
    Marin avatar
    1057 posts

    Posted 02 Nov 2011 Link to this post

    Hi Valera,

     When you add an ajax setting to the RadAjaxManager it wraps the button in a update panel, and specifies that the button itself will be the initiator of the asynchronous request. The content in the update panel is changed only if the server returns a different HTML response. So in this case there is no one-way or two-way ajax request. The ajax request is only one and it is triggered when you click the button. This is the way that all the ASP.NET update panels work. They specify a control that will trigger the request and an area wrapped in the update panel that can possibly be changed if the server returns different response.
    Alternatively you can manually trigger an ajax request from the client and handle it on the server, this way you will not need to specify ajax settings for the button. More information on how to do this is available in this help topic:

    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  3. Kevin
    Kevin avatar
    360 posts
    Member since:
    Jul 2012

    Posted 02 Nov 2011 Link to this post

    Hello Valera,

    You don't really need to use an Ajax request to perform an asynchronous request. You could use a callback instead, which should increase performance as it doesn't run through the whole page lifecycle like Ajax does. So it could look something like this:

    public partial class _Default : System.Web.UI.Page, ICallbackEventHandler 
        protected void Page_Load(object sender, EventArgs e) 
        // hold callback return value 
        string returnValue; 
        public string GetCallbackResult() 
            return returnValue; 
        public void RaiseCallbackEvent(string args) 
                  // send email and determine if email was sent or not
                  bool emailSent = SendEmail();
                      returnValue = "Email Sent";
                      returnValue = "Email Not Sent"

    function SendEmail(arg) { 
                          // call callback
                         <%=Page.ClientScript.GetCallbackEventReference(this, "arg", "ReceiveResult", "null") %>; 
                catch (e) { 
            function ReceiveHitResult(value) { 

    All you need to do then is attach the SendEmail function to the button click event to perform the callback. I'm showing an alert when the callback finishes to alert the user if the email was sent or not. You don't need to do anything in the ReceiveResult method, you can leave it empty if you want.

    I hope that helps.
  4. Valera
    Valera avatar
    2 posts
    Member since:
    Jul 2011

    Posted 02 Nov 2011 Link to this post

    Thank You -

    Using Callback addresses my problem perfectly!
Back to Top