Rad Ajax partial postback problem

5 posts, 0 answers
  1. Edward
    Edward avatar
    5 posts
    Member since:
    Jul 2010

    Posted 12 Aug 2010 Link to this post


    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="TestPartialPostback.aspx.vb"
        Inherits="Rentware.TestPartialPostback" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head runat="server">
        <form id="form1" runat="server">
         <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <br />
            <telerik:RadFormDecorator ID="rfDecorator" runat="server" DecoratedControls="Buttons,Fieldset,RadioButtons,CheckBoxes" />
            <telerik:RadWindowManager runat="server" ID="radWindowMgr" />
            <telerik:RadAjaxManager ID="radAjaxMgr" runat="server">
                <telerik:AjaxSetting AjaxControlID="cbTest">
                        <telerik:AjaxUpdatedControl ControlID="testPanel" />
                Account Management</h2>
            <telerik:RadTabStrip ID="RadTabsAccManage" runat="server" MultiPageID="RadMultiPageAccManage"
                SelectedIndex="0" Skin="WebBlue">
                <telerik:RadTab Text="General">
                <telerik:RadTab Text="Contacts">
            <telerik:RadMultiPage ID="RadMultiPageAccManage" runat="server" SelectedIndex="0">
                <telerik:RadPageView ID="RadPageViewAccManageGeneral" runat="server">
                    <telerik:RadGrid ID="RadGridAccManageMain" runat="server" GridLines="None" AutoGenerateColumns="False"
                        ShowStatusBar="true" AllowAutomaticDeletes="True" AllowAutomaticInserts="True"
                        AllowAutomaticUpdates="True" DataSourceID="SqlDataSource1">
                        <alternatingitemstyle cssclass="DisplayNone" />
                        <itemstyle cssclass="DisplayNone" />
                        <headerstyle cssclass="DisplayNone" />
                        <footerstyle cssclass="DisplayNone" />
                        <groupingsettings casesensitive="false" />
                        <mastertableview gridlines="None" datasourceid="SqlDataSource1" autogeneratecolumns="false"
                            <telerik:GridTemplateColumn ItemStyle-HorizontalAlign="Center" AllowFiltering="false">
                        <EditFormSettings EditFormType="Template">
                                <asp:CheckBox ID="cbTest" runat="server" Text="Enable" TextAlign="Left"
                                    OnCheckedChanged="checkBoxCheckedChanaged" AutoPostBack="true" />
                                <asp:Panel ID="testPanel" runat="server" Enabled="false">
                                        <legend>Add Or Edit Region:</legend>Region Description:
                                        <asp:TextBox runat="server" ID="txtText" Text='<%#Bind("RegionDescription") %>' />
                    <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
                        ProviderName="System.Data.SqlClient" SelectCommand="SELECT [RegionID], [RegionDescription] FROM [Region] WHERE ([RegionID] = @RegionID)"
                            <asp:SessionParameter Name="RegionID" SessionField="regionId" Type="Int32" />
                <telerik:RadPageView ID="RadPageViewAccManageContacts" runat="server">
    Imports Telerik.Web.UI
    Partial Public Class TestPartialPostback
        Inherits System.Web.UI.Page
        Dim regionId As Integer
        Dim commandName As String
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If Not Page.IsPostBack Then
                regionId = Convert.ToInt32(Convert.ToString(Request.QueryString("regionId")))
                Session("regionId") = regionId
            End If
            commandName = IIf(Session("regionId").Equals(0), "PerformInsert", "Update").ToString()
        End Sub
        Private Sub RadGridAccManageMain_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGridAccManageMain.ItemCreated
            If TypeOf e.Item Is GridEditableItem AndAlso commandName = "Update" Then
                e.Item.Edit = True
            End If
        End Sub
        Protected Sub RadGridAccManageMain_PreRender(ByVal sender As Object, ByVal e As EventArgs) Handles RadGridAccManageMain.PreRender
            If Not Page.IsPostBack And commandName = "PerformInsert" Then
                RadGridAccManageMain.MasterTableView.IsItemInserted = True
                RadGridAccManageMain.HeaderStyle.CssClass = "rgEditRow"
            End If
        End Sub
        Protected Sub checkBoxCheckedChanaged(ByVal sender As Object, ByVal e As System.EventArgs)
            Dim thisCheckBox As CheckBox = CType(sender, CheckBox)
            Dim editItem As GridEditFormItem = DirectCast(thisCheckBox.NamingContainer, GridEditFormItem)
            CType(editItem.FindControl("testPanel"), Panel).Enabled = thisCheckBox.Checked
        End Sub
    End Class

    I’m using RadGrid for editing and inserting row in the place of using asp.net form view.  I’m passing the parameter to select the row for editing through query string.I’m assigning that query string to session variable in page load event and that session variable serves as select parameter in SQL Data source.If I get the required query string I’m putting RadGrid in Item Edit Mode and if not It will open the RadGrid in Item Insert mode.Inside Form Template I’ve a checkbox and asp.net panel that wraps all other contents of Form Template. I have an event to handle check box checked status changed.In that event I’m enabling and disabling the panel based on if the checkbox is checked or not.


    I’ve RadAjaxManager in place with Ajax settings.  I’ve an AJAX setting in that RadAjaxManager with AjaxControlID as ID of the checkbox and AJAX updated control ID as the ID of the panel. So If I check or uncheck the checkbox In either Edit Mode or Insert Mode the panel should be enabled or disabled through AJAX partial post back.



    If the page loaded in insert mode for the first time and if I check the checkbox it is doing full post back and I can observe that clearly. (This is not expected behaviour).If I check the checkbox again it is doing partial ajaxified post back.But In Edit mode it is working fine (doing partial ajaxified post back) at all time.How I can fix this issue. For your reference I’ve attached the aspx and code behind file for you. It is stopping us from progressing further; your help would be very much appreciated.

  2. Veli
    Veli avatar
    2002 posts

    Posted 18 Aug 2010 Link to this post

    Hello Edward,

    There are several issues with your AJAX settings and your current scenario. First, you specify server IDs of controls that are instantiated multiple times in a template. However, if you happen to initialize 2 edit forms at once, or an edit form and an insert form, which CheckBox and which Panel should get AJAX? One AJAX setting refers to one initiator and one updated control. Also, you can specify declarative AJAX settings only for controls that can be found either directly at the page level, or using FindControl() from the page. In effect, you are not advised to use declarative AJAX settings for control nested in naming containers or binding containers (that multiply them when databound). In your scenario, you have to programmatically add AJAX settings for these nested controls instead. Furthermore, you have to make sure your AJAX settings are added exactly once.

    You can actually put an item in edit more, or put the master table in insert mode right on initial load where you check your query string parameters. I have attached a test page to demonstrate this. Check it out.

    Kind regards,
    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
  3. Veli
    Veli avatar
    2002 posts

    Posted 18 Aug 2010 Link to this post

    Hello Edward,

    Forgot to remove the declarative AJAX setting from the RadAjaxManager in the test page. Your RadAjaxSettings are all created in the code-behind, so you do not have any AJAX settings in the markup:

    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">

    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
  4. Amit
    Amit avatar
    14 posts
    Member since:
    Sep 2012

    Posted 07 Feb 2014 Link to this post

    i have same scanario and same problem/bug in my application i have widely used telerik control in my application so its not possible to change in design or adding ajax setting , so is there any other solution i can do with my application to avoid such problem . any one can help?
  5. Maria Ilieva
    Maria Ilieva avatar
    4017 posts

    Posted 12 Feb 2014 Link to this post

    Hi Amit,

    As this thread is rather old and since the last reply we have made several improvements in the RadAjax behavior it would be best if you could open s separate forum post/support ticket which presents the exact scenario you have and the problematic behavior you are facing. Thus we will be able to concentrate on your specific case and advise you further.

    Maria Ilieva
    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 UI for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top