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

Button clicks repeating themselves

3 Answers 62 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris McGrath
Top achievements
Rank 1
Chris McGrath asked on 19 Jul 2010, 11:57 PM
Hello,

I've got a RadAjaxPanel, which contains a RadGrid, which contains some ASP buttons inside its CommandItemTemplate, including an Export To Excel button, which exports that grid's data.  The button itself works fine and the excel file is returned.  But after exporting, if I click my Update button elsewhere on the page, after the postback, the Excel file pops up again! 

I've tested with different scenarios and found that any of my buttons in that panel are getting re-called if they're called once and then a subsequent button is clicked.  I tried moving the buttons outside of the grid, and the same thing happened.  I moved the buttons outside of the panel, and the problem went away... but of course then the buttons no longer use AJAX and are not nicely placed in the grid where they belong. =)

So any idea what would cause the button's click event to happen even when it wasn't that button that was clicked?  It's almost like it's stored that a click should happen and it keeps clicking the button on every postback, no matter what actually caused it.

It's on a very complex page, but here are some code snippets that might be applicable.

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="AttorneyPanel" />
                <telerik:AjaxUpdatedControl ControlID="ButtonsPanel" />
                <telerik:AjaxUpdatedControl ControlID="DocumentsPanel" />
                <telerik:AjaxUpdatedControl ControlID="FundingsPanel" />
                <telerik:AjaxUpdatedControl ControlID="CaseCountsPanel" />
                <telerik:AjaxUpdatedControl ControlID="RemindersPanel" />
                <telerik:AjaxUpdatedControl ControlID="ReductionPanel" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="AttorneyPanel">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="FundingsPanel" />
                <telerik:AjaxUpdatedControl ControlID="DocumentsPanel" />
                <telerik:AjaxUpdatedControl ControlID="CaseCountsPanel" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="ButtonsPanel">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="FundingsPanel" />
                <telerik:AjaxUpdatedControl ControlID="DocumentsPanel" />
                <telerik:AjaxUpdatedControl ControlID="CaseCountsPanel" />
                <telerik:AjaxUpdatedControl ControlID="RemindersPanel" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>

<telerik:RadAjaxPanel ID="CaseListPanel" runat="server" ClientEvents-OnRequestStart="requestStart" EnableAJAX="true" OnAjaxRequest="CaseListPanel_AjaxRequest">
 
    <div class="box" style="width:95%;" align="center">
        <div class="boxheader">Attorney Case List</div>
        <telerik:RadGrid ID="CaseListGrid" runat="server" AllowSorting="True" AllowPaging="False"
                         OnNeedDataSource="CaseListGrid_NeedDataSource" OnPreRender="CaseListGrid_PreRender"
                         OnItemDataBound="CaseListGrid_ItemDataBound"
                         Skin="Oasis" EnableEmbeddedSkins="false" Width="100%" AllowFilteringByColumn="true" SortingSettings-EnableSkinSortStyles="false" OnItemCreated="CaseListGrid_ItemCreated" >
        <ClientSettings AllowColumnsReorder="true" >
            <Scrolling AllowScroll="False" UseStaticHeaders="True" />
            <Resizing AllowColumnResize="true" />
            <ClientEvents OnGridCreated="GridCreated3" /> 
        </ClientSettings>
          
        <MasterTableView AllowMultiColumnSorting="True" AutoGenerateColumns="False" AllowFilteringByColumn="true"
                         TableLayout="Auto" CommandItemDisplay="Top" ClientDataKeyNames="CaseId">
            <CommandItemTemplate>
                <asp:Button ID="DownloadPDF" runat="server" Text="Create Pdf" OnCLick="downloadPdf_Click" />
                <asp:Button ID="DownloadExcel" runat="server" Text="Create Excel" OnClick="downloadXLS_Click" />
                <asp:Button ID="showsum" Text="Show All" OnClick="show_all_Click" runat="server" />
            </CommandItemTemplate>

protected void downloadXLS_Click(object sender, EventArgs e)
{
    CaseListGrid.MasterTableView.ExportToExcel();
}

3 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 22 Jul 2010, 12:15 PM
Hi Chris McGrath,

I can see you are both using RadAjaxManager and RadAjaxPanel. Note that, if you are using both of these controls to AJAX-ify one and the same content, this is not a supported scenario. Only a single AJAX control can be used on a DOM subtree. Additionally, you need to disable AJAX when exporting. The RadGrid Export demo shows how to do that.

Regards,
Veli
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
Chris McGrath
Top achievements
Rank 1
answered on 22 Jul 2010, 03:38 PM
Thanks for the response.  I was actually able to figure out the problem and while it may have been related to the conflict you point out, I don't think the actual problem was a direct result of it, but some of our own code.

That said, I'd like to understand the relationship between ajax panels and the ajax manager.  I've inherited a lot of this code from another developer so I've mostly just worked with what he already had going. 

What would be the proper way to make sure that one panel gets updated via ajax when a button from a different panel is clicked?  We thought we had to use panels and the ajax manager in conjunction in order to link multiple panels together.
0
Accepted
Veli
Telerik team
answered on 22 Jul 2010, 05:10 PM
Hi Chris,

The general RadAjax rule is very simple - do not mix different RadAjax controls to AJAX-ify one and the same content. While regular ASP.NET UpdatePanels support this scenario, this is not the case with RadAjax controls. This means you can use regular Panel controls (not RadAjaxPanel) with RadAjaxManager in the same scenario you have so far. In this case, AJAX is provided by the RadAjaxManager only.

Alternatively, you can use RadAjaxPanels and remove RadAjaxManager. In this case, AJAX is provided by your RadAjaxPanels only. The important point here is not let different AJAX controls interfere with each other.

In your case, you already have a scenario setup where buttons in one panel update content in other panels, so sticking to RadAjaxManager in your case would, I believe, be more appropriate. Only, the updated content should be contained in Panels. You need to remove the RadAjaxPanels if you were using them.

All the best,
Veli
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
Tags
Grid
Asked by
Chris McGrath
Top achievements
Rank 1
Answers by
Veli
Telerik team
Chris McGrath
Top achievements
Rank 1
Share this question
or