So, I have text entered in textbox, which I need to show as preview in label. Problem is, it has specific formatting, so @A is trigger for red color, and text is red colored util some other text color sign is inserted (like we at some point insert @B and text is green from that point, and so on).
That wouldn’t be big problem if there weren’t two problems:
- Obviously this is web application, and although is written in C#, many things that can be done on windows forms, can’t be done here.
-
Bigger problem, that I can’t solve is that I also have signs for text background and for text hight (which I would solve in classes).
font color red_____________green___________blue__________ font bacgr. black_________________________________red_____ font hight normal_________________double_________________
I hope you get it, I have three groups of parameters (font color, background color, and text hight) and parameter from one group should change one property, and others should stay.
This is sure complicated, but at least I would need idea how to make that for example @A triggers that color of text in Label becomes red, and that @A is deleted, and when after that is for example @B, at that point text becomes green, and so on.
Have in mind that this is ASP.NET, so many C# features are not available.
The simplest way to accomplish this would be parse the string for your tags and replace them with equivalent HTML/CSS tags (<span class=”red”>) that implement the formatting you want.