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

Using RadRichTextBox as forum editor

11 Answers 254 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
hwsoderlund
Top achievements
Rank 1
hwsoderlund asked on 03 Feb 2011, 05:35 PM
I am in the process of implementing forum functionality within our product, and I had pretty much decided to use RadRichTextBox for the editing functionality. But just now it struck me that it might not be that simple. Think of a plain old forum, like this one. Maybe I am missing something, but wouldn't each post in a forum thread need its own RadRichTextBox instance just to display the text? And wouldn't that be a huge performance impact if you have, say, 250 forum posts in one thread? Sure, we could implement paging within threads to keep the number of instances down, but still. What are your thoughts on my scenario? Is it feasible at all? Is there a different way of simply displaying a RadDocument, or does it always need to be hosted within a RadRichTextBox?

Best regards,
/Henrik

11 Answers, 1 is accepted

Sort by
0
hwsoderlund
Top achievements
Rank 1
answered on 08 Feb 2011, 01:30 PM
I would very much appreciate some input on this. Thank you.
0
Mike
Telerik team
answered on 08 Feb 2011, 02:22 PM
Hello hwsoderlund,

As you have guessed in order for your application to have good performance you have to keep the instances of RadRichTextBox and in fact any other visual elements to a minimum. Thus showing 200+ RichTextBoxes is not a great option. One possible approach would be to use some kind of virtualizing control such as ListBox, DataGrid or a custom one and prepare a data template with a RichTextBox for each item of this control. This way only the visible control instances would be loaded. Let us know if you meet any obstacles on the way.

Greetings,
Mike
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
hwsoderlund
Top achievements
Rank 1
answered on 09 Feb 2011, 03:03 PM
Yes, the possibility of using virtualization occurred to me also, but I quickly gave that up since I cannot find a way to combine it with smooth scrolling. Each item in a forum thread will obviously have a considerable height, in the case of a long post much higher than the viewport, and if the scrollviewer cannot scroll smoothly between these items, virtualization is simply not an option.

I have done a little feasibility study now and sadly come to the conclusion that RadRichTextBox is not going to work for me. It is far too heavy and memory intensive to be used in a multiple-instance scenario like this. What I did was put the Microsoft RichTextBox control in the item template of an items control and compared the performance against RadRichTextBox when used in the same fasion. When displaying a short document (3-4 paragraphs of text), I could easily generate a couple of hundred instances of MS RichTextBoxes and still get decently smooth scrolling and a reasonable memory footprint (awful compared to html displayed in a web browser, but still acceptable). With RadRichTextBox I could generate no more than 20 items until the page became almost unusable. When generating 40 items it took about 6-7 seconds for them to even appear. Any more than that and the page crashed and burned in some sort of layout cycle exception. And I have not even mentioned memory consumption. I am attaching my test project for your convenience. Please take a look and see for yourselves.

While RadRichTextBox seems to be a very powerful component when used in a single instance for reading and writing large documents, I feel that you have completely missed the scenario where a rich text component is used to display small "islands" of rich text scattered throughout a page. Surely I cannot be the only person needing a rich text component for a scenario such as this? I know I have seen forum threads asking about using RadRichTextBox in a cell within RadGridView. That is a pretty similar scenario to mine.

I want to ask you to consider implementing something like a RadRichTextBlock, stripped of all editing functionality, context menus, spell checking etc. and only used to render and display rich text produced using RadRichTextBox. The only interactivity needed (at least that I can think of) would be text selection.

Alternatively, is there a way of pulling Xaml from RadRichTextBox that can be rendered using a plain MS RichTextBox? Or maybe "normal" xaml that could just be displayed in a ContentControl? If I could do that I would have a workaround at least.

Sample project:
http://cid-cc43a90a79374ebd.office.live.com/self.aspx/Public/RichTextBoxTest01.zip

Best regards,
/Henrik
0
Iva Toteva
Telerik team
answered on 11 Feb 2011, 05:06 PM
Hi Henrik,

Thank you for taking the time to examine the issue in such detail and for the sample project.
We have indeed not considered the possible use of RadRichTextBox in a forum. We have however tested the performance when having many RadRichTextBoxes on one page and are quite satisfied with the results. A prerequisite for that has always been a panel that supports UI virtualization. We strongly advise you against giving up UI virtualization irregardless of your choice for a container of the messages. There are various approaches to implementing your own virtualizing panel on the web, if the standard ones do not offer the user experience you are looking for.
Another option you might want to consider is editing the messages in a RadRichTextBox and showing them in MS RichTextBoxes. We have a simple provider that can convert a RadDocument to and from the XAML that MS RichTextBox uses. We can send its source code to you in the support ticket you opened, so that you can test it and develop it further if needed. It, however, strips some formatting from the RadDocument as RichTextBox supports less formatting options than RadRichTextBox does. Also, note that this format provider will be shipped with the next major release along with the other officially supported ones.
Let us know if that answers your question and the way you wish to proceed.

Greetings,
Iva
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
hwsoderlund
Top achievements
Rank 1
answered on 11 Feb 2011, 05:59 PM
The MS RichTextBox provider sounds like the simple option, so I would like to try that first. :) And yes, I agree that it would be best to use virtualization, but I have never seen a solution where smooth scrolling and virtualization work in harmony. If you know of one, please post the link, because that would be the perfect solution for me. But I am thinking that any virtualization technique would have to assume a certain height for each UI item in the list. Since forum posts vary so much in length (from a few sentences to several pages of content) I am guessing that it will be very difficult to implement a stable virtualization mechanism with smooth scrolling. The only thing I can think of would be to actually try and calculate the height of each forum post when it is being posted/edited, and save that height value to db. Then when reading back the forum posts the virtualization mechanism would read that data and already know the height of each item. Thus it would be able to accurately calculate the needed space for each post. But this is just me rambling. I have no idea of how long it would take me to implement something like this. Probably weeks, and I simply do not have that kind of time to spend on this project.

Anyway, thanks for the suggestion about the new provider. Please send me the code in the support ticket and I will try it out. It definitely sounds like it could work. It would be great if you could also elaborate a little on what formatting properties will be lost when using that provider.

I would also appreciate some feedback on my idea for a light weight read-only rich text viewer (RichTextBlock if you will). To me that sounds like quite a useful addition to your component suite. I mean, we are not just talking about forums. Any application with smaller text areas like help texts, advanced tooltips, user comments, sticky notes etc. would benefit from the use of rich text rather than just plain text. And using the full RadRichTextBox in read-only mode for these purposes just seems so overkill. Sure, it will work fine on my quad-core dev machine, but I am pretty sure that my 3 year old netbook will be less happy if I render 5-7 instances of RadRichTextBox on the same page and load it up. Just give the idea some thought, that is all I ask.

Best regards,
/Henrik
0
Rabeeh
Top achievements
Rank 2
answered on 14 Feb 2011, 11:15 AM
This quite challenging, but I have been working on a project where I need to load over 2000+ RadRichTextBox, the only way to do this is by using paging.

The paging algorithm consists of creating only a set of RadRichTextBox, for our case it was 25. For the next page you use the same created controls and re-initialize them. that way your application can scale well.

0
hwsoderlund
Top achievements
Rank 1
answered on 14 Feb 2011, 12:41 PM
@Rabeeh. Yes, that is a not a bad idea. I might have to switch to that approach. The current UI design that I have to implement is using hierarchical forum threads, which does not work so well together with paging. But I might be able to convince people that a flat forum view is the way to go, and in that case I would be able to switch to a paged design. I just hate limiting myself because of technical issues. Even if we would go with a flat forum design now, I still want to be able to add a hierarchical view later if it becomes necessary. Anyway, what sort of performance did you get with the 25 richtextboxes on the same page? In the test project I posted it takes several seconds to render 20 instances of RadRichTextBox, and the RadDocuments I am loading are pretty simple.
0
Rabeeh
Top achievements
Rank 2
answered on 14 Feb 2011, 12:55 PM
Yes, it will take some time to render the controls, loading the Dictionary to the SpellChecker takes almost a second. But of course it will load one time, and the other controls will use it using MEF.

I think u will have an issue with typing speed inside the RadRichTextBox when you have a large text inside.

It is important to choose the right technology in advance for your project.

I have been building a multi-threaded comment system using asp.net and jquery for about a month now. I droped Silverlight because of the performance issues. 
0
hwsoderlund
Top achievements
Rank 1
answered on 15 Feb 2011, 10:55 AM
Yes, the html/css/javascript route would be a better choice for a forum, but  In this case I have no choice but to work with Silverlight. Our entire application is built in SL, and the coming forum/communication functionality is only a small part of that app. But thanks for the heads up about the typing speed. I have not done much testing with larger documents yet.

@Telerik: See, I am not the only one with performance issues here.

Best regards,
/Henrik
0
Iva Toteva
Telerik team
answered on 16 Feb 2011, 05:10 PM
Hi Henrik, 

Thank you for the follow-up and the constructive suggestions.
@Rabeeh Thank you for sharing your experience and taking active part in this discussion. 

To the topics raised:

  1. As for your suggestion of a RadRichTextBlock, RadRichTextBox in read-only mode is in fact stripped of all additional overhead that comes from the editing options and there is little that can be done at this point to optimize the performance. 
    We have some ideas for improvements but still adding a lot of RichTextBox controls with lots of text to the Silverlight app element tree will have relatively poor performance. So, unless you decide to use virtualization or a limitted number of posts/ rich text boxes a page, unfortunately, RadRichTextBox may not be the right choice for you. 
    Another Idea for optimization at your side is to substitute the read-only RichTextBox-es with images (using WriteableBitmap) or HtmlPalaceHolders.The solution with HtmlPlaceHolder though is limited to Web-Browser apps only and the HtmlPlaceHolder content is not actually native for Silverlight and animations and some other Silverlight UI goodies will not work.
  2. The solution with RichTextBoxes for the read-only posts turns out to be an option of limited capabilities, as RichTextBoxes do not support inline images and lists;
  3. When it comes to the poorer performance with larger documents, that is quite natural. However, when virtualization is utilized, the performance is bearable even for documents of more than 100 pages.
If I had missed to address a point in your comments or you have other questions, do not hesitate to get back to us.

Kind regards,
Iva
the Telerik team
0
Tony
Top achievements
Rank 1
answered on 06 Aug 2012, 05:09 PM
I just wanted to mention I had a similar need as well where I need to have a couple of hundred RichText controls on a page. I had implemented my solution originally with the Microsoft RichTextBox and it worked flawlessly. I liked the Telerik RTB control and converted to it just to find out that 30 - 40 controls on a page made the page unusuable... quickly locking up my browser.... even in read only mode.

It would be really nice if telerik created a very very simple RTB control without all the bells and whistles... kind of like the one im typing in that only has bold,italic, indenting and a couple of other options.

Just wanted to thumbs a need for a leaner RTB...

Back to the MS control for now.

Tags
RichTextBox
Asked by
hwsoderlund
Top achievements
Rank 1
Answers by
hwsoderlund
Top achievements
Rank 1
Mike
Telerik team
Iva Toteva
Telerik team
Rabeeh
Top achievements
Rank 2
Tony
Top achievements
Rank 1
Share this question
or