load on demand with confirmation

2 posts, 0 answers
  1. Fred
    Fred avatar
    45 posts
    Member since:
    Apr 2009

    Posted 26 Mar 2012 Link to this post

    Hi,
    I have adapted the load on demand demo to show a confirmation box before load the next control. If the control currently loaded is in "Edit mode" i want to show a confirmation box, so i use the following code: 

    protected void RadTabStrip1_TabClick(object sender, RadTabStripEventArgs e)
    {
    if
    (isEdit)
      {
                    
                RadTabStrip1.FindTabByText(LatestMenuItem).Selected = true;
                RadAjaxManager manager = RadAjaxManager.GetCurrent(this.Page);
                manager.ResponseScripts.Add("if(confirm('Are you sure?'))" + manager.ClientID + ".ajaxRequest('tab')");
      }
      else
       {
                   LatestMenuItem = e.Tab.Text;
                   string ctrl = e.Tab.Attributes["ctrl"] + ".ascx";
                   LoadUserControl(ctrl,false);
                   e.Tab.Selected = true;
         }
    }

    If the user click yes then i initiate an Ajax request to load the user control.

    protected void ManagerAjaxRequest(object sender, AjaxRequestEventArgs e)
    {
    LoadUserControl(NewControlName,
    true);
    }

    I also have the following RadAjax Settings on page:

    <telerik:RadAjaxManagerProxy ID="RadAjaxManager1" runat="server" >
     <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="RadTabStrip1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RadTabStrip1" />
                            <telerik:AjaxUpdatedControl ControlID="Panel1" LoadingPanelID="RadAjaxLoadingPanel1" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                     
                    <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RadTabStrip1" />
                            <telerik:AjaxUpdatedControl ControlID="Panel1" LoadingPanelID="RadAjaxLoadingPanel1" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
         
                         
     </telerik:RadAjaxManagerProxy>

    If i debug the code i can see the control is loaded and added correctly, but nothing happens on the page. Any tips on load user controls in the ManagerAjaxRequest method?


    Thanks.


  2. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 29 Mar 2012 Link to this post

    Hi,

    The reason for the experienced behavior are your Ajax settings. By default such setting is not a valid one when applied to the RadAjaxManagerProxy:
    <telerik:RadAjaxManagerProxy ID="RadAjaxManager1" runat="server" >
     <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="RadTabStrip1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RadTabStrip1" />
                            <telerik:AjaxUpdatedControl ControlID="Panel1" LoadingPanelID="RadAjaxLoadingPanel1" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                      
                    <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RadTabStrip1" />
                            <telerik:AjaxUpdatedControl ControlID="Panel1" LoadingPanelID="RadAjaxLoadingPanel1" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>                           
     </telerik:RadAjaxManagerProxy>

    In scenarios like yours when you have RadAjaxManager with RadAjaxManagerProxy and need to add a setting that the manager will update a certain control than this setting should be added programmatically from code behind.

    Greetings,
    Dimitar Terziev
    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. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top