Is it possible to do this ?
Let me explain this.
// aspx
<asp:TextBox runat="server" ID="txtOld" TextMode="MultiLine" Columns="70" Rows="30" Width="425px" />
<asp:TextBox runat="server" ID="txtNew" TextMode="MultiLine" Columns="70" Rows="30" Width="425px" />
<asp:Button Text="Compare" runat="server" ID="btnCompare" OnClick="btnCompare_Click" />
// c#
I have two string
string strOld = "This a line 1\nThis is going to be line 2\rThis is going to be line 3\rThis is line 4";
string strNew = "This a line 1\nThis text is changed here going to be line 2\rThis is going to be line 3\rThis is changed line 4";
Please note that these strings have \n and \r in it.
When form loads, I do something like this
if (!IsPostBack)
{
txtOld.Text = strOld;
txtNew.Text = strNew;
}
Web browser automatically splits the strings and align nicely in the Text box like this
txtOld TextBox renders like this
This a line 1
This is going to be line 2
This is going to be line 3
This is line 4
txtNew TextBox renders like this
This a line 1
This text is changed here going to be line 2
This is going to be line 3
This is changed line 4
Now when hit compare button, I need to mark the lines and change the color of the lines in the text box which are different,
for example
Line 2 and line 4 in the above example.
I may be able to compare the strings but how do I mark and change color of the lines in the text box.
Please advice.
Someone replied in other post that its good idea to do this at client side using javascript.
Is it possible do that in javascrit and change the color of the lines of TextBox
Thanks
Let me explain this.
// aspx
<asp:TextBox runat="server" ID="txtOld" TextMode="MultiLine" Columns="70" Rows="30" Width="425px" />
<asp:TextBox runat="server" ID="txtNew" TextMode="MultiLine" Columns="70" Rows="30" Width="425px" />
<asp:Button Text="Compare" runat="server" ID="btnCompare" OnClick="btnCompare_Click" />
// c#
I have two string
string strOld = "This a line 1\nThis is going to be line 2\rThis is going to be line 3\rThis is line 4";
string strNew = "This a line 1\nThis text is changed here going to be line 2\rThis is going to be line 3\rThis is changed line 4";
Please note that these strings have \n and \r in it.
When form loads, I do something like this
if (!IsPostBack)
{
txtOld.Text = strOld;
txtNew.Text = strNew;
}
Web browser automatically splits the strings and align nicely in the Text box like this
txtOld TextBox renders like this
This a line 1
This is going to be line 2
This is going to be line 3
This is line 4
txtNew TextBox renders like this
This a line 1
This text is changed here going to be line 2
This is going to be line 3
This is changed line 4
Now when hit compare button, I need to mark the lines and change the color of the lines in the text box which are different,
for example
Line 2 and line 4 in the above example.
I may be able to compare the strings but how do I mark and change color of the lines in the text box.
Please advice.
Someone replied in other post that its good idea to do this at client side using javascript.
Is it possible do that in javascrit and change the color of the lines of TextBox
Thanks