Click here to Skip to main content
15,905,028 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a web form with several text fields. When a user makes a change to one of these field, it is requested that the old and new data is shown in a different color, probably using a rich text box.

What I have tried:

I tried to google for a solution, as well as asking this question on other forums.
Posted
Updated 20-May-16 6:50am
Comments
ZurdoDev 20-May-16 10:36am    
There are many ways to do this so the first step you need to do is decide how you want the UI to look. Then you can go about and write the code.
Member 10854933 20-May-16 10:43am    
I have the UI almost completed. For the text fields which are nvarchar(max) fields, I would use something like a rich text control.

So when the data is revised in the form, how would all of the changes appear in different colors?
Karthik_Mahalingam 20-May-16 11:56am    
how will you show the old and new values in the same richtextbox?
Member 10854933 20-May-16 12:00pm    
That is the question I am asking
Karthik_Mahalingam 20-May-16 12:04pm    
you mean, part of the text or whole text ?
if so it will be confusing for the end users, to show both the data in single textbox is not a good idea, you shall try to displaying the old data in a label or some other control.

if you found anything like that, give the url.

Have a look at DiffPlex[^]. It includes a sample ASP.NET MVC website that shows how to display the differences between two strings in various formats.
 
Share this answer
 
Comments
Member 10854933 20-May-16 13:06pm    
Does Diffplex show the differences in text in the rich text control.

I am guessing the different versions would be in separate records in the table and use a query to get the differences between the two (or more) records.

Then I want to display the the text for the first record and any changes to the text in a different color in the same control.

Diffplex appears to work like Winmerge (this is not what i want)
Richard Deeming 20-May-16 13:09pm    
It generates the differences by line, word or character; you can then display them however your want.
Before you start worrying about the UI, you need to define and code to support the "this is different bit" and then work out exactly how you want to display it.
Start with Google: difference between two files c - Google Search[^] and find somethign that works for you - this isn't trivial stuff by any means - and then start thinking about what to display and how. Do you want to show stuff that was deleted? Added? A small change? A big change? These aren't simple decisions and they aren't all easy to detect accurately.
The actual UI stuff is trivial once you have decided exactly what you need to display and how you want to display it: a RichTextBox can use colours, underline, bold, italic, ... and they are all specified in similar ways. Google will tell you how to do that - but concentrate on identifying changes first - thats the difficult bit!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900