Full post-back occurring for controls added to RadAjaxManagerProxy

2 posts, 0 answers
  1. Matt
    Matt avatar
    78 posts
    Member since:
    Mar 2009

    Posted 26 Feb 2014 Link to this post

    I have a main page that contains the radAjaxManager.  Then, on a user control, I have the following defined:

    <telerik:RadAjaxManagerProxy ID="rampObjectIndexInfo" runat="server" />
    <telerik:RadAjaxLoadingPanel ID="ralpObjectIndexInfo" runat="server" />

    Within the user control, I create a series of dynamic controls.  At some times, we create repeating rows of fields where the user can add additional rows (e.g., we initially define 2 rows of three text boxes, but the user can add additional rows as they desire).  We define the buttons as follows (only the minus button is shown, the plus button is defined pretty much the same):

    ImageButton minusButton = new ImageButton();
    minusButton.ImageUrl = GetString("ObjectDetails.IndexingInfo.RepeatingRowRemove.ImageName");
    minusButton.AlternateText = GetString("ObjectDetails.IndexingInfo.RepeatingRowRemove.AltText");
    minusButton.OnClientClick = "RemoveLine('" + dataGroupId + "', 'btnpm_" + dataGroupId + "_" + controlSuffix + "'," + controlSuffix + ");";
    minusButton.ID = epCustom.ID + "_M_" + (controlSuffix);
    minusButton.Style.Add("padding-right", "3px");

    //Index info is an array of dynamically created controls that will be displayed to the user
    indexInfo.Controls.Add(minusButton);
    rampObjectIndexInfo.AjaxSettings.AddAjaxSetting(minusButton, minusButton.Parent, ralpObjectIndexInfo);

    The issue I'm having is that instead of executing the OnClientClick event, a full post-back is executed and the form is entirely reloaded (which is what we're trying to avoid since there are a half-dozen other controls that update as well and that causes a major performance hit).

    What am I missing?
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 26 Feb 2014 in reply to Matt Link to this post

    Hi Matt,

    The provided code is working fine at my end. Please have a look into the sample code snippet which works fine at my end. Please provide your full code if it doesn't help.

    ASPX:
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    </telerik:RadAjaxManager>
    <uc1:Usercontrol1 ID="Usercontrol11" runat="server" />

    ASCX:
    <telerik:RadAjaxManagerProxy ID="rampObjectIndexInfo" runat="server" />
    <telerik:RadAjaxLoadingPanel ID="ralpObjectIndexInfo" runat="server" Skin="Default" />

    UserContol Page JavaScript:
    <script type="text/javascript">
        function RemoveLine() {
            alert("Fired");
        }
    </script>

    ASCX.CS:
    protected void Page_Load(object sender, EventArgs e)
    {
        ImageButton minusButton = new ImageButton();
        minusButton.ImageUrl = "~/Images/BlackPlus.png";
        minusButton.AlternateText = "Alternate Text";
        minusButton.OnClientClick = "RemoveLine();";
        minusButton.ID = "ImageButton1";
        minusButton.Style.Add("padding-right", "3px");
     
        this.Controls.Add(minusButton);
        rampObjectIndexInfo.AjaxSettings.AddAjaxSetting(minusButton, minusButton.Parent, ralpObjectIndexInfo);
    }

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top