I want to show Two different colors in the same textbox at the same time see the image for understanding. And the image is my sample UI design.
[The concept is when the page is loaded I'm fetching the data from Database and showing it in the textbox textmode = "multiline" and] I want to show the "A" is Green color and "B" is Red color and I tried the below code to achieve this but I'm getting the all text color as "Red" or "Green" only because it is overriding based on the last txtbox.ForeColor
line execution.
ASPX :-
<asp:TextBox ID="txtbox" runat="server" TextMode="MultiLine" Width="950px" Height="510px"></asp:TextBox>
Note :- Based on my Live working code condition sometimes it will go to if condition and else condition also
C# :-
string A = "A";
string B = "B";
if(....)
{
txtbox.Text += A+" : "+"Hi";
txtbox.Text += A+" : "+"The color is Green";
txtbox.Text += A+" : "+"Ok";
txtbox.ForeColor = System.Drawing.Color.Green;
}
else
{
txtbox.Text += B+" : "+"Hello";
txtbox.Text += B+" : "+"The color is Red";
txtbox.Text += B+" : "+"Ok";
txtbox.ForeColor = System.Drawing.Color.Red;
}
Suggest me how can I achieve this?