This is a migrated thread and some comments may be shown as answers.

RadHtmlPlaceholder Null with multiple tabs

1 Answer 29 Views
HTMLPlaceHolder
This is a migrated thread and some comments may be shown as answers.
omkar
Top achievements
Rank 1
omkar asked on 16 Jul 2015, 10:55 AM
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

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 20 Jul 2015, 08:31 AM
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
Tags
HTMLPlaceHolder
Asked by
omkar
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or