How to highlight the differences between two versions of text in a .NET web application?

I have been supporting a web application for working in our Call Center for about 2 years. The application is written in ASP.NET 3.5 with a SQL Server 2005 database. I was asked to expand the call details section to allow agents to edit the current call note with the option to revert to the previous version. Now all this is cool, but now the manager wants to be able to click on any note and see all the changes with the changes highlighted in yellow (and if something has been deleted, he wants to see the deleted text crossed out). Actually, I really like the way Stackoverflow handles changes in its issues. I was thinking about how to do this, and after conducting research and Google courses, of course, I still do not know which route to take. I am new to .NET development. Any ideas on the best way to highlight changes in the user interface? I’m afraid that I will have to keep a copy of the entire note every time they make changes, because the manager wants to be able to easily view notes and return to ANY version (and not just the latest one) before sending a monthly call report to our VIP clients. As this OFTEN department changes its mind about things, I want new features to be scalable and easy to maintain. Any ideas are greatly appreciated. I'm really just looking for someone to point me in the right direction; maybe there are some tools that might be useful, recommended keywords in a google search, etc.

+4
source share
4 answers

It will be hard to do.

  • You will need a “text editor” control that can not only edit the text, but can also tell you what changes have been made.
  • Then you need to save not only the final text string, but also the list of changes
  • Then you will need to display the text plus the changes, using strikeouts and different colors for the inserts and changes.
  • You will need to do this not only for changes of one user, but you will need to store the changes of each user in the database and will have to be able to display all the changes, all at once.

Your manager must be sure that he needs it.

+2
source

Some diff tools for you can be found in Any decent diff / merge text engine for .NET? .

This will entail the preservation of each version, as you say. This should allow you to implement it similarly to SO. I seem to remember reading or hearing how Jeff mentioned it, but couldn't find it, probably in one of the SO podcasts.

+1
source

The easiest way is to save the text for each revision, and then when the user wants to see diff, use the diff tool to create the selected text.

Here is the javascript code: http://ejohn.org/projects/javascript-diff-algorithm/

If Word is installed on all computers, you can use the Word control to do this. TortoiseSVN has scripts in its program directory that can accept two-word documents and create a document with highlighted changes. To see this, create c: \ aaa.doc and bbb.doc, then install TortoiseSVN and run:

wscript.exe "C:\program files\tortoisesvn\Diff-Scripts\diff-doc.js" c:\aaa.doc c:\bbb.doc //E:javascript 
+1
source
0
source

All Articles