How do i Line break in tooltip?

5 posts, 0 answers
  1. Khwaja
    Khwaja avatar
    5 posts
    Member since:
    Mar 2009

    Posted 09 Mar 2009 Link to this post

    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

  2. Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 12 Mar 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Khwaja
    Khwaja avatar
    5 posts
    Member since:
    Mar 2009

    Posted 31 Mar 2009 Link to this post

    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

     

     

  5. Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 03 Apr 2009 Link to this post

    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.
  6. Nicolaï
    Nicolaï avatar
    160 posts
    Member since:
    Apr 2008

    Posted 02 Feb 2015 Link to this post

    Environment.NewLine
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017