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

How do i Line break in tooltip?

4 Answers 1783 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
Khwaja
Top achievements
Rank 1
Khwaja asked on 09 Mar 2009, 06:13 PM
Hi,

I am using RadToolTipManager control and displaying tooltip. Tooltip text i am reading from the database.
for normal text i am able to display tooltip with no problem, but in my text there are carriage return characters (like \n \r),
that causes problem and does not display and gives me error.

Please see code:

 

private void PopulateQuestion()

 

{

lblSectionName.Text =

this.Question.PageTitle;

 

divSection.Visible = (

this.Question.PageTitle != string.Empty);

 

lblQuestionSequence.Text =

"Q." + this.Question.Sequence.ToString() + " - ";

 

lblQuestionText.Text =

this.Question.QuestionText;

 

 

// Set help icon alt text

 

 

//imgHelp.AlternateText = this.Question.AdditionalContent;

 

 

//imgHelp.Attributes.Add("title", this.Question.AdditionalContent); // For FireFox

 

 

// string s = "Khwaja \n saiyed";

 

 

// string newstr = s.Replace("\n", "<br/>");

 

 

//this.RadToolTipManager1.TargetControls.Add(imgHelp.ClientID, s.ToString(), true);

 

 

this.RadToolTipManager1.TargetControls.Add(imgHelp.ClientID, this.Question.AdditionalContent.ToString(), true);

 

 

}


 

 

protected void RadToolTipManager1_AjaxUpdate(object sender, Telerik.Web.UI.ToolTipUpdateEventArgs e)

 

{

 

Label lblInsideToolTip = new Label();

 

lblInsideToolTip.Text = e.Value;

e.UpdatePanel.ContentTemplateContainer.Controls.Add(lblInsideToolTip);

 

 

 

 

}


I hope this makes sense to all of you.

Thanks
Khwaja

4 Answers, 1 is accepted

Sort by
0
Svetlina Anati
Telerik team
answered on 12 Mar 2009, 01:52 PM
Hi Khwaja,

I tested the rendering when the tooltip contains <br/> elements but it behaves exactly as you require - it is represented with a new line. This being said, all you should do is just to replace the \n ,\r, etc special characters with <br/> which is standard string manipulation task and is not related to RadToolTip.

Greetings,
Svetlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Khwaja
Top achievements
Rank 1
answered on 31 Mar 2009, 04:02 PM
Thanks for your reply.
I can display tooltip without any problem if there are no carriage return characters. i am displaying dynamic additional text from the database and adding into this.RadToolTipManager1.
eg. 
private void PopulateQuestion()
{
...
this.RadToolTipManager1.TargetControls.Add(imgHelp.ClientID, this.Question.AdditionalContent.ToString(), true);
..}

 protected void RadToolTipManager1_AjaxUpdate(object sender, Telerik.Web.UI.ToolTipUpdateEventArgs e)
       {
           Label lblInsideToolTip =
new Label();
           lblInsideToolTip.Text =
e.value;
           e.UpdatePanel.ContentTemplateContainer.Controls.Add(lblInsideToolTip);
       }

if any carriage return (\n,\r)  in 
this.Question.AdditionalContent  it gives me an error.

As you said use. replace..
i tried that way as well but it didn't work for dynamic text.
i trid:

string

 

mstr =  this.Question.AdditionalContent.ToString();
string newstr = mstr.Replace("\n","<br/>");
this.RadToolTipManager1.TargetControls.Add(imgHelp.ClientID, newstr.ToString() , true);

Not working...

Can you please tell me, how can i workout this problem..

Thanks
Khwaja

 

 

0
Svetlina Anati
Telerik team
answered on 03 Apr 2009, 09:59 AM
Hi Khwaja,

Please, try to replace all the special signs, not only the \n but the \r, too. Make also sure that your database code along with the result after the replace are correct - simply debug the project and find out what actually gets passed as a value parameter to the tooltip manager. If the passed string does not include any special signs and you still experience the problem, open a new support ticket and send us a sample, fully runnable reproduction demo which can be run without any modifications along with detailed reproduction instructions and we will do our best to help.

Regards,
Svetlina
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Nicolaï
Top achievements
Rank 2
answered on 02 Feb 2015, 03:07 PM
Environment.NewLine
Tags
ToolTip
Asked by
Khwaja
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
Khwaja
Top achievements
Rank 1
Nicolaï
Top achievements
Rank 2
Share this question
or