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

ChatTextMessage Hyperlink

3 Answers 238 Views
Conversational UI, Chat
This is a migrated thread and some comments may be shown as answers.
Stephen
Top achievements
Rank 1
Stephen asked on 30 Nov 2018, 12:11 AM

Hi,

First of all, kudos for having developed the chat control--I will be purchasing the Winforms UI license solely for this capability!

I noticed that the text of a ChatTextMessage can be HTML-formatted.  When I create a hyperlink, it looks and acts like one, with the exception that the link target is not launched when I click on it.  How can I overcome this?

3 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 03 Dec 2018, 09:05 AM
Hello, Stephen,    

Thank you for the kind words. We are happy to hear that RadChat is suitable for your scenario.

As to the question about the hyperlinks, I have prepared a sample code snippet for your reference:

this.radChat1.Author = new Author(Properties.Resources.bot, "Nancy");
Author author2 = new Author(Properties.Resources.bot,"Andrew");
 
ChatTextMessage message1 = new ChatTextMessage("Hello", author2,DateTime.Now.AddHours(1));
this.radChat1.AddMessage(message1);
 
ChatTextMessage message2 = new ChatTextMessage("Hi", this.radChat1.Author,DateTime.Now.AddHours(1).AddMinutes(10));
this.radChat1.AddMessage(message2);
 
string textWithLink = @"<html><size=12>Please visit <a href=www.telerik.com>Telerik</a>" ;
ChatTextMessage message3 = new ChatTextMessage(textWithLink, author2,DateTime.Now.AddHours(3));
this.radChat1.AddMessage(message3);



Additional information about the supported HTML-like text formatting is available in the following help article: https://docs.telerik.com/devtools/winforms/telerik-presentation-framework/html-like-text-formatting

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress TelerikRadChat for Winforms
lata
Top achievements
Rank 1
commented on 15 Jul 2024, 07:59 PM | edited

Hi Dess,
I tried this solution. however, It is not working for me. It is adding as a text only. not adding as a link.
Please let me know, what I am missing ?

I found the rootcause why this is not displaying as a link at my side. I have also implemented copy functionality for message. https://docs.telerik.com/devtools/winforms/knowledge-base/how-to-select-and-copy-text-in-chat-messages
Internally, it is using RadTextBoxControlElement for message.  Please let us know how it will display hyperlink if we implement above functionality for copy.

 string textWithLink =@"<html><size=12>Please visit <a href=www.telerik.com>Telerik</a></html>";
 ChatTextMessage message3 = new ChatTextMessage(textWithLink, author2, DateTime.Now.AddHours(3));
 this.radChat1.AddMessage(message3);
Dinko | Tech Support Engineer
Telerik team
commented on 16 Jul 2024, 12:39 PM

You are on the right track. The RadTextBoxControlElement can't visualize hyperlinks in its text. The text control of the control is visualized char by char. The same questions were discussed in this forum thread. What was suggested in the forum was to use RadRichTextEditor control. However, this control is a heavy control, and integrating it inside the chat message item could lead to performance problems. At this moment of writing this reply, I can't suggest a way to have a selection behavior of the text and visualize hyperlinks at the same time.
lata
Top achievements
Rank 1
commented on 16 Jul 2024, 01:11 PM | edited

Hi Dinko,
Thanks for responding !!
Another query regarding this -
If I am not implementing CustomChatFactory for copy functionality ( https://docs.telerik.com/devtools/winforms/knowledge-base/how-to-select-and-copy-text-in-chat-messages)

Just using default ChatFactory, then it is displaying hyperlink. But when I am clicking on the link then it is not navigating to the url page. So after clicking to link how it will navigate to URL ?

Code -
  string textWithLink = @"<html><size=12>Please visit <a href=www.telerik.com>Telerik</a></html>";
            ChatTextMessage message3 = new ChatTextMessage(textWithLink, author1, DateTime.Now.AddHours(3));
            this.radChat1.AddMessage(message3);

Dinko | Tech Support Engineer
Telerik team
commented on 17 Jul 2024, 11:49 AM

I have tested it on my side and clicking on the Telerik hyperlink text opens the default web browser specified in my Windows OS. Can you check my test project and let me know if this behavior is still observed. If yes, something is interfering while the link is opening.
0
Stephen
Top achievements
Rank 1
answered on 03 Dec 2018, 04:28 PM

This is PERFECT!  It's working fine for me.  My problem originally was that I was putting quotation marks around the link reference.

Thanks again.  I purchased the WinForms license for 3 years and am excited about this component.

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 04 Dec 2018, 11:16 AM
Hello, Stephen,    

Thank you for the kind words. I am really thrilled to hear that the provided code snippet was useful for your case and you probably have plans to further use our RadChat control. 

Should you have further questions please let me know.

Regards,
Dess | Tech Support Engineer, Sr.
Progress TelerikRadChat for Winforms
Tags
Conversational UI, Chat
Asked by
Stephen
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Stephen
Top achievements
Rank 1
Share this question
or