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

Add new Item,edit is causing postback

1 Answer 69 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Venkatesh asked on 04 Dec 2012, 05:50 AM
I am using the "RadControls for ASP.NET AJAX Q3 2012" in Sharepoint 2010.
I have added the Rad Grid and also added the ajax. However, when i click "add new item" or edit items in the grid, the grid is doing a postback. I have added the below code:

    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1"></telerik:AjaxUpdatedControl>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
    <telerik:RadGrid ID="RadGrid1" runat="server" 
        ShowFooter="True" onitemcommand="RadGrid1_ItemCommand" 
        onupdatecommand="RadGrid1_UpdateCommand" >
    <MasterTableView DataKeyNames="Title" AutoGenerateColumns="false" EditMode="InPlace" CommandItemDisplay="TopAndBottom" CommandItemSettings-AddNewRecordText="Add New Item" >
                     <telerik:GridEditCommandColumn ButtonType="ImageButton">
                        <telerik:GridButtonColumn ConfirmText="Delete this product?" ConfirmDialogType="RadWindow"
                            ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" ConfirmDialogHeight="100px"
                     <telerik:GridTemplateColumn DataField="Title" HeaderText="Product Number" UniqueName="ProductNumber"
                                <telerik:RadTextBox ID="RadtxtPrdNumber" runat="server" Text='<%# Bind("Title") %>' >
                                <telerik:RadTextBox ID="RadtxtPrdNumber" runat="server" Text='<%# Eval("Title") %>' >
                            <telerik:RadTextBox ID="RadtxtPrdNumber" ReadOnly="true" runat="server" Text='<%# Eval("Title") %>' />
     <ClientSettings EnableRowHoverStyle="true">

How to fix this?

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 06 Dec 2012, 11:58 AM

 When you use RadAjaxManager in Sharepoint 2010 the ajax settings have to be created entirely in the code-behind of the web part as shown below:

RadAjaxManager ajaxmgr;
        protected override void OnInit(EventArgs e)
            ajaxmgr = RadAjaxManager.GetCurrent(Page);
            if (ajaxmgr == null)
                ajaxmgr = new RadAjaxManager();
                Page.Items.Add(typeof(RadAjaxManager), ajaxmgr);
            if (Page.Form != null)
                Page.Form.Controls.AddAt(0, ajaxmgr);
        protected override void CreateChildControls()
            Control control = Page.LoadControl(_ascxPath);
            RadAjaxLoadingPanel loadingPanel = control.FindControl("RadAjaxLoadingPanel1") as RadAjaxLoadingPanel;
            RadGrid grid = control.FindControl("RadGrid1") as RadGrid;
            //Find more controls to add to the ajax settings
            if (ajaxmgr != null)
                ajaxmgr.AjaxSettings.AddAjaxSetting(grid, grid, loadingPanel);

Additional information can be found in this help topic:

All the best,
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.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question