radgrid gridhyperlinkcolumn tooltip with newline

3 posts, 0 answers
  1. Susan Hessler
    Susan Hessler avatar
    13 posts
    Member since:
    May 2006

    Posted 04 Nov 2015 Link to this post

    Using vb.net....  I have a radgrid with a gridhypercolumn.  I have added a tool tip in the ItemDataBound subroutine.  I am grabbing the tooltip text from a field in the database.  I cannot figure out what character(s) I need to put in the string so that I can display "Line one. <br \> Line two. \n Line three. &#013;" like:

    Line one.

    Line two.

    Line three.


    I have tried <br \>, \n, &#013;.  I have even set the tooltip to "eval('"Line one. <br \> Line two. \n Line three. &#013;")" with no luck.


    I also have the following in the style tags:

    .tooltip-inner {

             white-space: pre-wrap;





  2. Marin Bratanov
    Marin Bratanov avatar
    4819 posts

    Posted 06 Nov 2015 Link to this post

    Hi Susan,

    RadToolTip uses HTML, so the line separator would be <br />

    How this is to be stored in your database, however, is up to the concrete case (e.g., you may need to encode the HTML string before storing and decode it after storing, depending on your DB setup).

    Let's take the following demo for an example: http://demos.telerik.com/aspnet-ajax/tooltip/examples/targetcontrolsandajax/defaultcs.aspx?product=tooltip. Here is how it can be modified to show simple HTML (I am pasting only the changed code):

    private void UpdateToolTip(string elementID, UpdatePanel panel)
        string content = string.Format("<div class=\"tooltip-inner\">line one {0}<br />Second line {0}<br />Line 3: {0}</div>", elementID);
        panel.ContentTemplateContainer.Controls.Add(new LiteralControl(content));
        //Control ctrl = Page.LoadControl("ProductDetailsCS.ascx");
        //ctrl.ID = "UcProductDetails1";
        //ProductDetailsCS details = (ProductDetailsCS)ctrl;
        //details.ProductID = elementID;

    To make the example simple, I am using a literal to add HTML directly, instead of using a user control.

    If you find it easier, however, you can create your layout (including the line breaks) in the user control and populate it with data as shown in the demo.

    If I am mistaken and you actually use the ToolTip server property of the HyperLink control, the line separator is \n for the browser tooltips. Here is an example (based on this demo again, but uses browser tooltips and not RadToolTips):

    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)
            Control target = e.Item.FindControl("targetControl");
            if (!Object.Equals(target, null))
                (target as HyperLink).ToolTip = string.Format("Line one: {0}\nSecond line: {0}\nLine 3: {0}", (e.Item as GridDataItem).GetDataKeyValue("ProductID").ToString());


    Marin Bratanov
    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. Susan Hessler
    Susan Hessler avatar
    13 posts
    Member since:
    May 2006

    Posted 06 Nov 2015 in reply to Marin Bratanov Link to this post

    I use this data in more than one place so...  In the database, I have <br />, which works everywhere except the tooltip.  To get it to work in the tooltip, I replaced all "<br />" with vbNewLine and it works! 


Back to Top