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

Tooltip with line feed

2 Answers 62 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
Tracy
Top achievements
Rank 1
Tracy asked on 07 Oct 2012, 12:35 AM
Hi,

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
 
       Else
           'If no companies are check set prpSelectedValue and the prpToolTip to Nothing,
           If prpSelectedCount = 0 Then
               prpSelectedValue = ""
               prpToolTip = ""
           Else
               '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.Clear()
       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
       e.UpdatePanel.ContentTemplateContainer.Controls.Add(lblToolTip)
   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.
Tracy

After I add the new line

2 Answers, 1 is accepted

Sort by
0
Accepted
Marin Bratanov
Telerik team
answered on 08 Oct 2012, 10:34 AM
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;


Regards,
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.
0
Tracy
Top achievements
Rank 1
answered on 11 Oct 2012, 03:14 AM
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

Tracy
Tags
ToolTip
Asked by
Tracy
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Tracy
Top achievements
Rank 1
Share this question
or