RadHtmlPlaceholder Null with multiple tabs

2 posts, 0 answers
  1. omkar
    omkar avatar
    1 posts
    Member since:
    May 2015

    Posted 16 Jul 2015 Link to this post

    Hi Team,

    We are using RadTabControl and RadHtmlPlaceholder (created class by deriving from RadHtmlPlaceholder). With one tab everything works fine. However when we create 2 tabs, unable to invoke JavaScript. Since getting  “HtmlPresenter” as null.

    Please find code below to invoke JavaScript code (calling below method after HtmlPlaceholder_UrlLoaded).

    Can you please let us know any pointer or solution.

    HtmlElement m1 = (HtmlElement)this.HtmlPresenter.Children[0];

                    // Set an ID to the HTML element so that can be used later when calling the javascript
                    m1.SetAttribute("id", "myHtmlElement");
                    //Invoking the JavaScript function:

                    HtmlWindow loadedPage = (m1.GetProperty("contentWindow") as HtmlWindow);

                    if (loadedPage != null)
                        loadedPage.Invoke(methodName, args);


    Thanks and Regards,
    Omkar
  2. Martin
    Admin
    Martin avatar
    1099 posts

    Posted 20 Jul 2015 Link to this post

    Hi Omkar,

    Note that, RadTabControl loads the content of its tabs on demand. In other words it loads the Content of a certain tab when the tab is selected and then when the selection is changed the Content of the new selected tab is loaded and the old content is removed from the visual tree. So, if the RadHtmlPlaceholder control is placed into a tab that is not selected, you won't be able to get its HTML presenter.

    You can alter this behavior by setting the tab control's IsContentPresevered property to True. This will prevent the control from destroying the Content of the tabs when the selection is changed. However, even in this case you will need to select the tabs at least once in order for its contents to be loaded.

    As a side note, I just want to note you that there were a duplicate of this forum post and I removed it.

    Regards,
    Martin
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  3. DevCraft banner
Back to Top