What If Ajaxified Control and Updated Control Are The Same...

2 posts, 1 answers
  1. Courtney
    Courtney avatar
    1 posts
    Member since:
    Aug 2014

    Posted 08 Sep 2014 Link to this post

    In the AddAjaxSetting(Control ajaxifiedControl, Control updatedControl) method, is it ok for both Control arguments to be the same object? For example:

    radAjaxMgr1.AjaxSettings.AddAjaxSetting(myCustomEditor, myCustomEditor);

     myCustomEditor is of the type WebControl. It looks like myCustomEditor is going to respond to some client-side action on itself, but is that allowed by the RadAjaxManager?

    Thanks!
  2. Answer
    Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1803 posts

    Posted 11 Sep 2014 Link to this post

    Hello Courtney,

    The AjaxControlID in the AjaxSettings of the RadAjaxManager specifies for which controls to enable AJAX. The UpdatedControls collection in other hand specifies which controls should be updated when an AJAX request in initiated from the AjaxControlID from the AjaxSettings.

    Having the above in mind, if you want to update the control initiating the AJAX request, you could add it in the UpdatedControls collection.

    I think that the following examples will help you understand how exactly those settings work.

    1) One control as initiator and one control to be updated:
    <telerik:RadAjaxManager runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadButton1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadButton2" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
     
    <telerik:RadButton runat="server" ID="RadButton1"></telerik:RadButton>
    <telerik:RadButton runat="server" ID="RadButton2"></telerik:RadButton>

    And the code-behind:
    protected void Page_Load(object sender, EventArgs e)
    {
        RadButton1.Text = DateTime.Now.ToString();
        RadButton2.Text = DateTime.Now.ToString(); 
    }

    As you can see, clicking on the first button initiates an AJAX request, but updates only the second button, because it is the only one in the UpdatedControls collection.

    2) One control as initiator, but two controls in the UpdatedControls:
    <telerik:RadAjaxManager runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadButton1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadButton1" />
                    <telerik:AjaxUpdatedControl ControlID="RadButton2" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
     
    <telerik:RadButton runat="server" ID="RadButton1"></telerik:RadButton>
    <telerik:RadButton runat="server" ID="RadButton2"></telerik:RadButton>

    In this scenario, both of the buttons will be updated.

    Hope this helps.


    Regards,
    Konstantin Dikov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     

Back to Top