What's _contentWrapper, why it's null, and how to initialize it?

4 posts, 0 answers
  1. أشرف
    أشرف avatar
    88 posts
    Member since:
    Jan 2011

    Posted 19 Dec 2013 Link to this post


    Whenever I try to call the client side set_contentElement method of any tooltip object I get a null reference error because _contentWrapper is null. Here's the relevant excerpt from the RadControls code:
    It tries to set the innerHTML of _contentWrapper, but it's set to null, so the code breaks.

    What's the role of _contentWrapper? And how to initialize it?
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 19 Dec 2013 Link to this post

    Hi Ashraf,

    Please have a look into the sample code snippet I tried and check this online demo and help documentation for further information about ContentElement in RadToolTip.

    <asp:ListBox ID="lbSelectedLanguages" runat="server" Width="151px">
        <asp:ListItem Text="Click to select"></asp:ListItem>
    <telerik:RadToolTip runat="server" ID="RadToolTip3" HideEvent="ManualClose" Position="MiddleRight"
        <asp:CheckBoxList ID="cblLanguages" runat="server">
            <asp:ListItem Text="English" Value="en"></asp:ListItem>
            <asp:ListItem Text="German" Value="de"></asp:ListItem>
            <asp:ListItem Text="French" Value="fr"></asp:ListItem>
        <asp:Button ID="Button1" runat="server" Text="Select" OnClientClick="InsertLanguages(); return false;">

    <script type="text/javascript">
        function InsertLanguages() {
            var tooltip = $find("<%=RadToolTip3.ClientID %>");
            //get the html element, holding the content of the tooltip
            var contentElement = tooltip.get_contentElement();
            //set a new html element to tooptip
            contentElement.innerHTML = "<span>demo</span>";

  3. أشرف
    أشرف avatar
    88 posts
    Member since:
    Jan 2011

    Posted 21 Dec 2013 Link to this post

    Greetings and thanks for your reply,

    The tooltip I have is created in the code not the markup. I created a custom control that displays itself in a tooltip.
    I instantiate a tooltip and add a Literal control to its Controls collection.

    I'm not on my office now, but when I was there, I tested with a RadTooltip created in the markup, that has a static DIV with some text in the content template, and still the problem occurred.

    I think this should be filed as a bug, or otherwise Telerik should give instructions on how to instantiate this object.
  4. أشرف
    أشرف avatar
    88 posts
    Member since:
    Jan 2011

    Posted 22 Dec 2013 Link to this post

    With the setup you created, if I call set_contentElement the same problem occurs because _contentWrapper is null.

    After some digging I found that this hack solves the problem:
    var tooltip = $find("component id here");
            tooltip._createUI(); // HACK:

    Again calling a private member, which I don't like. My code has a lot of _ members references.
    I think _createUI should be public then.
Back to Top