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

RadGrid does postback when I try to use Ajax

1 Answer 28 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 12 Dec 2014, 04:37 PM
Good morning.

This is my first post, so I will do my best to cover everything as thoroughly as possible. I am implementing a RadGrid in an ASP.NET project. Here are the particulars:

Windows 7
IE 11
ASP.NET 4.5
preferred language is VB
latest version of Telerik Tools

I have followed the instructions of several examples I've found online, including some here, but to no avail. No matter what I do, when I click any button in my RadGrid - Add, Edit, Cancel, etc. I get a PostBack. After clicking any button, all subsequent attempts to interact with the RadGrid fail due to the postback. I just want to use AJAX. Here is my RadGrid code:

<telerik:RadGrid ID="attachment_list" runat="server"
    OnNeedDataSource="attachment_list_NeedDataSource"
    AutoGenerateColumns="False"
    AllowPaging="True"
    PageSize="30"
    AllowAutomaticDeletes="True"
    AllowAutomaticInserts="True"
    AllowAutomaticUpdates="True"
    OnEditCommand="attachment_list_EditCommand"
    GroupPanelPosition="Top" >           
    <HeaderContextMenu EnableAutoScroll="True"
    </HeaderContextMenu
    <MasterTableView                    
        CommandItemDisplay="Top"
        NoMasterRecordsText="There are currently no attachments">
        <CommandItemSettings AddNewRecordText="Attach Another File" />                        
        <RowIndicatorColumn
            <HeaderStyle Width="20px"></HeaderStyle
        </RowIndicatorColumn
        <ExpandCollapseColumn
            <HeaderStyle Width="20px"></HeaderStyle
        </ExpandCollapseColumn>
        <NoRecordsTemplate>
            <div ID="no_data_label">There are currently no attachments</div>
        </NoRecordsTemplate
        <Columns
            <telerik:GridBoundColumn DataField="AttachmentPath" HeaderText="File Name" UniqueName="FileName" ItemStyle-Width="340px">  
            </telerik:GridBoundColumn
            <telerik:GridBoundColumn DataField="AttachmentDescriptors" HeaderText="Description" UniqueName="Desc" ItemStyle-Width="450px">  
            </telerik:GridBoundColumn>                       
            <telerik:GridBoundColumn DataField="LastUpdatedDate" HeaderText="Updated Date" UniqueName="UpdatedDate" ItemStyle-Width="200px">  
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="UpdatedByName" HeaderText="Updated By" UniqueName="UpdatedBy" ItemStyle-Width="200px">  
            </telerik:GridBoundColumn>                                                     
            <telerik:GridButtonColumn ConfirmText="Are you sure you want to delete this item?" ConfirmDialogType="RadWindow" ConfirmTitle="Delete"
                ButtonType="ImageButton" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
                <ItemStyle HorizontalAlign="Center" CssClass="delete_button"></ItemStyle>
            </telerik:GridButtonColumn>
            <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                <ItemStyle CssClass="edit_button"></ItemStyle>
            </telerik:GridEditCommandColumn>                   
        </Columns>
                 
        <EditFormSettings EditFormType="Template">
            <FormTemplate>
                <asp:Panel ID="attachment_edit" runat="server" GroupingText='<%# IIf((TypeOf (Container) Is GridEditFormInsertItem), "Add an Attachment", "Update an Attachment")%>'>
                    <div class="inner_1">
                        <div class="float_left">
                            <asp:Panel ID="att_file_wrapper" runat="server">
                                <div class="label">Select File:</div>               
                                <telerik:RadUpload ID="att_file" runat="server" ReadOnlyFileInputs="True" ControlObjectsVisibility="none" ></telerik:RadUpload>
                            </asp:Panel>
                            <div class="label">Description:</div><asp:TextBox ID="att_desc" runat="server" Text='<%# Bind("AttachmentDescriptors")%>'></asp:TextBox>                                  
                        </div>                                   
                    </div>
                </asp:Panel>
 
                <div class="btn_group_small">
                    <asp:Button runat="server" ID="add_task" Text='<%# IIf((TypeOf (Container) Is GridEditFormInsertItem), "Add Attachment", "Update Attachment")%>'
                        CommandName='<%# IIf((TypeOf (Container) Is GridEditFormInsertItem), "Insert", "Update")%>' CssClass="small_btn" />
                    <asp:Button runat="server" ID="cancel_task" Text="Cancel" CommandName="Cancel"
                        CausesValidation="False" CssClass="small_btn" />
                </div>
 
            </FormTemplate>
        </EditFormSettings>                
    </MasterTableView>                       
</telerik:RadGrid>

Here is my Ajax Manager code (my primary RadAjaxManager is in the Matser page):

<telerik:RadAjaxManagerProxy ID="AjaxManagerProxy1" runat="server" >
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="attachment_list">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="attachment_list" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>                      
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManagerProxy>

I am fairly new to using Telerik (and .NET in general), and I'm on a tight deadline. Any assistance would be appreciated - thanks.

1 Answer, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 16 Dec 2014, 09:25 AM
Hello Mike,

The most common reason for the presented issue is having the RadAjaxManager added before the ScriptManager in the MasterPage markup. Please make sure that the RadScriptManager or the asp ScriptManager is placed on the very top of the MasterPage before all control's declaration and see if this helps.

Regards,
Maria Ilieva
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.

 
Tags
Ajax
Asked by
Mike
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Share this question
or