Page flickers when using RadAjaxManagerProxy

4 posts, 0 answers
  1. rod
    rod avatar
    10 posts
    Member since:
    Nov 2006

    Posted 16 Oct 2011 Link to this post

    Hello,

    I have the following radGrid:

    <telerik:RadGrid ID="radGrid"  OnItemDataBound="radGrid_ItemDataBound" OnItemCommand="radGrid_ItemCommand">
          <MasterTableView >
                                <Columns>
                                    ...
                                </Columns>
                                <NestedViewTemplate>
                                    <ParteControl:ParteControl id="ctl" visible="false" runat="server"/>
                                </NestedViewTemplate>
                            </MasterTableView>
                        </telerik:RadGrid>

    When I expand the row it fills the Usercontrol:

    protected void radGrid_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            if (e.CommandName == Telerik.Web.UI.RadGrid.ExpandCollapseCommandName)
            {
                if (!e.Item.Expanded)
                {
                    Label lblId = (Label)e.Item.OwnerTableView.Items[e.Item.ItemIndex]["Info"].FindControl("lblId");
                    controls_partescontrol ctl = (controls_partescontrol)((Telerik.Web.UI.GridDataItem)e.Item).ChildItem.FindControl("ctl");
     
                    String[] arrValues;
                    String srtValues = lblId.Text.ToString();
                    arrValues = srtValues.Split('#');
     
                    ctl.Pre();
                    ctl.Visible = true;
                    ctl.Value = arrValues[0].ToString();
                    ctl.Coluna = arrValues[1].ToString();
                    ctl.Load();
                }
            }
        }

    In the Usercontrol I have:

    <telerik:RadContextMenu ID="ctxMenu" runat="server">
            <Targets>
                <telerik:ContextMenuControlTarget ControlID="ajaxPanel" />
            </Targets>
            <Items>
                <telerik:RadMenuItem>
                    <ItemTemplate>
                        <asp:LinkButton ID="lnk_1" OnClientClick="javascript: callHoldInfo(this,'Parte');" OnCommand="Menu_ItemClick" CommandArgument="0" runat="server"  style="text-decoration: none !important;"></asp:LinkButton>
                    </ItemTemplate>
                </telerik:RadMenuItem>
                <telerik:RadMenuItem>
                    <ItemTemplate>
                        <asp:LinkButton ID="lnk_2" OnCommand="Menu_ItemClick" CommandArgument="1" runat="server"  style="text-decoration: none !important;"></asp:LinkButton>
                    </ItemTemplate>
                </telerik:RadMenuItem>
            </Items>
        </telerik:RadContextMenu>
        <asp:Literal ID="ltrError" runat="server"/>           
        <asp:Panel runat="server" id="ajaxPanel">
        </asp:Panel>

    and in the Code behind of the Usercontrol:

    if (this.Page != null)
            {
                RadAjaxManager ajaxManager = RadAjaxManager.GetCurrent(this.Page);
                if (ajaxManager != null)
                {
                    foreach (RadMenuItem item in ctxMenu.Items)
                    {
                        foreach (Control ctrl in item.Controls)
                        {
                            if (ctrl is LinkButton)
                            {
                                AjaxSetting ajaxSetting = new AjaxSetting(ajaxManager.ID);
                                ajaxSetting.AjaxControlID = ctrl.ID.ToString();
                                ajaxSetting.UpdatedControls.Add(new AjaxUpdatedControl(ltrError.ID.ToString(), "ajaxLoad"));
                                ajaxSetting.UpdatedControls.Add(new AjaxUpdatedControl(ajaxPanel.ID.ToString(), "ajaxLoad"));
                                ajaxManager.AjaxSettings.Add(ajaxSetting);
                            }
                        }
                    }
                }
            }


    The first Click the pages Flickers as it could not bind the Ajax Settings. Then the Click it work normally.

    I also tried to user the RadAjaxManagerProxy, but I could not make it work.

    Could you please give me some advise on how to get it right...


    Thank you very much,

    Rod.




  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 17 Oct 2011 Link to this post

    Hello Rod,

    The behavior you have described be experienced sice the control which contains the proxy is dynamically loaded and then added to the page after the init phase of page's lifecycle. In order to workaround this you may try instead using a RadAjaxManagerProxy to programmatically add the ajax setting to RadAjaxManager inside module's PreRender event.

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. rod
    rod avatar
    10 posts
    Member since:
    Nov 2006

    Posted 17 Oct 2011 Link to this post

    Hello Shinu,

    Thanks for your help, I tried before without success to use the following in the usercontrol:

    protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
     
            if (this.Page != null)
            {
                RadAjaxManager ajaxManager = RadAjaxManager.GetCurrent(this.Page);
                if (ajaxManager != null)
                {
                    foreach (RadMenuItem item in ctxMenu.Items)
                    {
                        foreach (Control ctrl in item.Controls)
                        {
                            if (ctrl is LinkButton)
                            {
                                AjaxSetting ajaxSetting = new AjaxSetting(ajaxManager.ID);
                                ajaxSetting.AjaxControlID = ctrl.ID.ToString();
                                ajaxSetting.UpdatedControls.Add(new AjaxUpdatedControl(ltrError.ID.ToString(), "ajaxLoad"));
                                ajaxSetting.UpdatedControls.Add(new AjaxUpdatedControl(ajaxPanel.ID.ToString(), "ajaxLoad"));
                                ajaxManager.AjaxSettings.Add(ajaxSetting);
                            }
                        }
                    }
                }
            }

    Do you think I could achieve the same result with something else? Do you know if I can use the OnClientClick/telerik:RadMenuItem?

    This way I could place the ajaxproxy in the front os my usercontrol instead of using it dynnamically...

    Thank you very much.

    Rod
  5. rod
    rod avatar
    10 posts
    Member since:
    Nov 2006

    Posted 19 Oct 2011 Link to this post

    Shinu,

    I used the:
    RadMenuItem mnu = ctl as RadMenuItem;
                        
                       if (mnu.Text == "...")
                       {
                           mnu.Attributes.Add("onclick", "javascript: callHoldInfo('" + ctxMenu.ClientID + "','...');");
                       }


    and on the modules page the RadAjaxManagerProxy... And it worked just like I wanted!!!

    Thanks,

    Rod
Back to Top