RadAjaxPanel - Can't find child links

3 posts, 0 answers
  1. Daniel
    Daniel avatar
    2 posts
    Member since:
    Oct 2008

    Posted 12 Jul 2010 Link to this post

    Hi,

    I have a page that contains a RadAjaxPanel, i am trying to write test code to validate the contents of a list that is async loaded in the ajaxPanel.

    Here is the basic structure of my page and UserControls:

    default.aspx
    <telerik:RadAjaxPanel ID="ajaxPanel_Activities"
    runat="server" EnableAJAX="true"
    LoadingPanelID="loadingPanel_Activities"
    RequestQueueSize="1">
         <div>
             <ahp:ActivitiesTabPanel runat="server" ID="activitiesTabPanel" />
         </div>
    </telerik:RadAjaxPanel>

     
    ahp.ahp:ActivitiesTabPanel UserControl
    <div class="wideColumn">
        <telerik:RadMultiPage ID="radMultiPage_ActivitiesLists" runat="server" SelectedIndex="0">
           <telerik:RadPageView ID="radPageView_ActivitiesListLive" runat="server">
                 <ahp:ActivitiesList ID="activitiesList_Live" runat="server"                   NumberOfResults="0" ReferenceActivityGroupName="Activities Page - Lives" OnMouseOver="showActivityContent('{0}', '{1}', '{2}');"         OnMouseOut="startTimer();"/>
            </telerik:RadPageView>
        </telerik:RadMultiPage>
    <div>


    ahp.ahp:ActivitiesList  UserControl

    <asp:Repeater ID="rptActivities" runat="server" OnItemDataBound="rptActivities_ItemDataBound" >
        <ItemTemplate>
           <asp:LinkButton ID="linkTopic" runat="server" Text='<%# Eval("Topic") %>' CommandName="Click" CommandArgument='<%# Eval("ActivityId") %>' OnCommand="activityLink_Command" />
        </ItemTemplate>
    </asp:Repeater>


    So I am trying to find all the HtmlAnchors that are rendered by the ahp:ActivitiesList  UserControl.
    But the linksInPanel Never contains the elements that are actually displayed.


    Here is my test code

    HtmlDiv ajaxPanel = _manager.ActiveBrowser.Find.ById<HtmlDiv>("ctl00_ctl00_cphContent_plcContent_ajaxPanel_Activities");
                Thread.Sleep(3000); //Give time for ajaxPanel to load.
     
                ReadOnlyCollection<HtmlAnchor> linksInPanel =ajaxPanel.Find.AllByTagName<HtmlAnchor>("a");
                HtmlAnchor match = null;
                foreach (HtmlAnchor ank in linksInPanel )
                {
                    if (activities.ActivityTarget[0].Topic.ToLower().Trim() == ank.BaseElement.InnerText.ToLower().Trim())
                    {
                        match = ank;
                        break;
                    }
                }
                Assert.IsTrue(match != null);


    Is this a limitation caused by the dynamically loaded markup in the ajaxPanel?
    Or am i just not looking for my links in the right way?

    Thanks for any help,
    Daniel
    delofer@aptilon.com
  2. Missing user
    Missing user avatar

    Posted 12 Jul 2010 Link to this post

    Hi Daniel,

    After the Thread.Sleep(3000),please try adding ActiveBrowser.RefreshDomTree(). If the panel happens to be in a frame, you can use the Find as in ActiveBrowser.Frames[index].Find, or if a popup window, Manager.Browsers[index].Find.

    If the links are not ancestors of the panel, then ajaxPanel.Find.AllByTagName may still not return anything. So please verify in the generated html if this is the case, and if not, please try using the Find on over another parent page element or using ActiveBrowser.Find.

    Sincerely,
    Nelson Sin
    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. Daniel
    Daniel avatar
    2 posts
    Member since:
    Oct 2008

    Posted 13 Jul 2010 Link to this post

    Hi Nelson,

    Thanks for the info, ActiveBrowser.RefreshDomTree() did the trick, that's all i was missing.

    Dan
Back to Top