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

RadConfirm then spinny

4 Answers 78 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Josh
Top achievements
Rank 1
Josh asked on 15 Oct 2010, 10:25 PM
Hi Support,

In my application, I have a sequence where the following happens.  The user clicks a button.  A radconfirm message box containing a callback function executes which then potentially executes more code based on whether the user clicks OK or Cancel.  If OK then more servier side code executes.  If Cancel nothing more happens.  This is all working fine with only one problem exists which I'm trying to remedy.  The problem is I would like a "spinny" to work as the code executes since the code takes a long time to finish.   To do this, I imagined I would put code that would ajaxify a panel containing an animated gif.  For example(note, the Button is not shown):

Aspx

 

<asp:Panel ID="PanelLoadPlace" runat="server" style="padding-bottom:5px;">

 

 

<asp:Label ID="LabelSpacerForLoadingPanel" runat="server" Width="100px" Height="20px" />

 

 

</asp:Panel>

 

 

 

<telerik:RadAjaxLoadingPanel ID="panelLoading" runat="server" Style="margin-top: 0px;"

 

 

HorizontalAlign="center" IsSticky="false" Transparency="30" InitialDelayTime="100"

 

 

MinDisplayTime="500">

 

 

<asp:Image ID="ImageLoading" runat="server" ImageUrl="~/Images/loading.gif" BorderWidth="0px"

 

 

AlternateText="Loading..." />

 

 

</telerik:RadAjaxLoadingPanel>

 


C#

 

protected void Manager_AjaxRequest(object sender, AjaxRequestEventArgs e)

 

{

RadAjaxManager

 

.GetCurrent(Page).AjaxSettings.AddAjaxSetting(Button, PanelLoadPlace, panelLoading);
}

However, this didn't work.  I tried placing the above line AddAjaxSetting line immediately after the RadConfirm and that didn't work either.  Any ideas?

Josh

 

4 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 18 Oct 2010, 10:25 AM
Hello Josh,

From the code snippets you provided I see that you add the ajax setting for the button inside the OnAjaxRequest server handler of the manager. This is not supported and in order to apply the ajax setting appropriately, you will need to add it either in the PageLoad or Page_PreRender handler as described in this topic.

Kind regards,
Sebastian
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Josh
Top achievements
Rank 1
answered on 02 Nov 2010, 11:26 PM
Hi Sebastian,

I finally got around to trying to do it the way you describe and I can't get it to work. 
I have pasted in the relevant code snippets.  When I do it this way, it doesn't produce the animated image at all.   The problem is I don't want to ajaxify every event with the spinny.  I only want the AjaxRequest event to be ajaxified with the Second Spinny. 
Interestingly, the PreRender Event condition of IsSecondSpinnyNeeded == true is met appropriately and the lines execute, but it doesn't successfully ajaxify the loading.gif.

(FYI, the first spinny works with AJAX in the markup; not shown here.  Thus, the IsSecondSpinnyNeeded property is set to true only after radconfirm event fires.  )

Any help you can give me is appreciated,
Josh

C#
protected void Page_Load(object sender, EventArgs e)
{
    // Hook up the toolbar to events on this page from the master
    Master.GetMasterToolBar().ButtonClick += new RadToolBarEventHandler(Plan_PlanMembershipFilter_ButtonClick);
}


    protected void Plan_PlanMembershipFilter_ButtonClick(object sender, RadToolBarEventArgs e)
    {
                    RadAjaxManager.GetCurrent(Page).ResponseScripts.Add(
                        "radconfirm('Once plan membership is generated selection criteria cannot be added or changed.  Continue?',"
                        + "CallBackFunctionGenerate, 300, 150,'','Plan Membership')");
                    this.IsSecondSpinnyNeeded = true;
}


/// <summary> 
    /// Store a value indicating whether or not the current plan has been processed 
    /// </summary> 
    private Boolean IsSecondSpinnyNeeded 
    
        get
        
            object isSecondSpinnyNeeded = ViewState["IsSecondSpinnyNeeded"]; 
            if (isSecondSpinnyNeeded != null
            
                return Convert.ToBoolean(isSecondSpinnyNeeded.ToString()); 
            
            return false
        
        set
        
            ViewState["IsSecondSpinnyNeeded"] = ((Boolean)value).ToString(); 
        
    
    
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
        if (Page.IsCallback)
        {
  
            if (this.IsSecondSpinnyNeeded == true)
            {
                RadToolBar masterToolBar = Master.GetMasterToolBar();
                RadAjaxManager manager = RadAjaxManager.GetCurrent(Page);
                //Add the necessary AJAX setting programmatically
                manager.AjaxSettings.AddAjaxSetting(masterToolBar, PanelLoadPlace, PanelLoading);
            }
            this.IsSecondSpinnyNeeded = false;
        }
    }
    
    protected void Manager_AjaxRequest(object sender, AjaxRequestEventArgs e) 
    
// Execute the necessary code 
    
    protected void Plan_PlanMembershipFilter_ButtonClick(object sender, RadToolBarEventArgs e) 
    
                    RadAjaxManager.GetCurrent(Page).ResponseScripts.Add( 
                        "radconfirm('Once plan membership is generated selection criteria cannot be added or changed.  Continue?',"
                        + "CallBackFunctionGenerate, 300, 150,'','Plan Membership')"); 
                    this.IsSecondSpinnyNeeded = true
}

aspx - markup
<asp:Panel ID="PanelLoadPlace" runat="server" style="padding-bottom:5px;">
    <asp:Label ID="LabelSpacerForLoadingPanel" runat="server" Width="100px" Height="20px" />  
</asp:Panel>
  
<telerik:RadAjaxLoadingPanel ID="PanelLoading" runat="server" Style="margin-top: 0px;"
    HorizontalAlign="center" IsSticky="false" Transparency="30" InitialDelayTime="100"
    MinDisplayTime="500">
    <asp:Image ID="ImageLoading" runat="server" ImageUrl="~/Images/loading.gif" BorderWidth="0px"
        AlternateText="Loading..." />
</telerik:RadAjaxLoadingPanel>   

JavaScript
//------------------------------------------------------------------------------
// This function returns true or false depending on the user's choice after generating
//------------------------------------------------------------------------------
function CallBackFunctionGenerate(arg)
{
    arg = "Generate:" + arg;
      
    // Invoking ajaxRequest             
    $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest(arg);
          
}
0
Sebastian
Telerik team
answered on 03 Nov 2010, 01:35 PM
Hello Josh,

I examined your modified code and here are my suggestions:
  • Remove this conditional check from your PreRender handler:

    if (Page.IsCallback)

    otherwise it will be executed on ASP.NET callback only.
  • Since you execute ajax request from the CallBackFunctionGenerate js method using the ajaxRequest(args) method of the ajax manager, I believe your ajax setting should be defined as follows:

    manager.AjaxSettings.AddAjaxSetting(RadAjaxManager.GetCurrent(Page) as RadAjaxManager, PanelLoadPlace, PanelLoading);

Additionally, debug your code inside the PreRender event handler to verify that the controls assigned in the dynamically defined ajax setting as referenced as expected.

Best regards,

Sebastian
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Josh
Top achievements
Rank 1
answered on 03 Nov 2010, 05:28 PM
Sebastian,

Thank you for your quick reply.  Once I applied both of your suggestions to my code it worked as desired!

Thanks again,
Josh
Tags
General Discussions
Asked by
Josh
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Josh
Top achievements
Rank 1
Share this question
or