Tooltip with line feed

3 posts, 1 answers
  1. Tracy
    Tracy avatar
    119 posts
    Member since:
    Nov 2010

    Posted 06 Oct 2012 Link to this post


    I have created a dynamic tooltip for a radcombobox with checkboxes.  As items in the combobox are checked or unchecked I change the tooltip for the combobox to the items that are selected.  I have been able to get this to work successfully using the following code.
    Private Sub rcbCompany_ItemChecked(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadComboBoxItemEventArgs) Handles rcbCompany.ItemChecked
           prpSelectedCount = Me.rcbCompany.GetCheckedIndices.Count
           Dim strToolTipField = IIf(prpDisplayType = "Name", e.Item.Text, e.Item.Value.ToString)
           If e.Item.Checked = True Then
               'If an item has been checked, add the company number to the prpSelectedValue list and the company code/name to the prpToolTip list.
               prpSelectedValue = prpSelectedValue + "," + e.Item.Attributes("CompanyNumber")
               prpToolTip = prpToolTip + strToolTipField
               'If no companies are check set prpSelectedValue and the prpToolTip to Nothing,
               If prpSelectedCount = 0 Then
                   prpSelectedValue = ""
                   prpToolTip = ""
                   'otherwise remove the unchecked company from the prpSelectedValue property
                   prpSelectedValue = prpSelectedValue.Replace("," + e.Item.Attributes("CompanyNumber"), "")
                   prpToolTip = prpToolTip.Replace(";" + strToolTipField, "")
               End If
           End If
           'Remove the extra comma, if any at the beginning of the string
           If prpSelectedValue.StartsWith(",") = True Then
               prpSelectedValue = prpSelectedValue.Remove(0, 1)
           End If
           If prpToolTip.StartsWith(";") = True Then
               prpToolTip = prpToolTip.Remove(0, 1)
           End If
           Me.rcbCompany.ToolTip = prpToolTip
           rttManagerCompany.TargetControls.Add(Me.rcbCompany.ClientID, True)
           RaiseEvent OnItemCheckedCompanyHandler(sender, e)
       End Sub
    Private Sub rttManagerCompany_AjaxUpdate(ByVal sender As Object, ByVal e As Telerik.Web.UI.ToolTipUpdateEventArgs) Handles rttManagerCompany.AjaxUpdate
           Dim lblToolTip As New Label()
           lblToolTip.Text = prpToolTip
       End Sub

    My problem becomes when I try to put in a new line in the tooltip text to separate the selected items.
    I changed the tooltip expression to

    prpToolTip = prpToolTip + "<br/>" + strToolTipField. 
    After I added the new line character(<br/>) I get the following error.
    Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500

    As a test to see if it was my generated tooltip that was causing the problem, I changed the lblToolTip.Text in the rttManagerCompany_AjaxUpdate to "line1 <br/> line2" and I still get the error.  If I remove the <br/> I do not get an error and the tooltip displays as line1line2. 

    Can anyone tell me how to get a new line in the tooltip.

    Thank you for your help.

    After I add the new line

  2. Answer
    Marin Bratanov
    Marin Bratanov avatar
    3908 posts

    Posted 08 Oct 2012 Link to this post

    Hi Tracy,

    This is a strange report. Adding a new line like this should work, it is merely the text of a span element in this case. I tried it in a simple page and it works fine with me. I am attaching it here as a reference along with a video from my experiment.

    The error you get is a server error and this means it may not be related to the tooltipmanager, but to something else in the code. I advise that you debug your code-behind to see where exactly the error is thrown and how to fix it.

    In the meantime you can also try escaping the br tag, e.g. &lt;br /&gt;

    Marin Bratanov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. Tracy
    Tracy avatar
    119 posts
    Member since:
    Nov 2010

    Posted 10 Oct 2012 Link to this post

    Hi Marin,
    Thank you for your response.  For some reason I was only able to fix my problem by setting the ValidateRequest=false on the page.  Maybe because I am putting the tooltip inside a user control.

    Thank You

Back to Top