I wanted a formatted text to be converted into unformatted text in the UI . for that I did the following
String strInput;
String strOutput;
strInput = txtEditorAnswer.Text;
strOutput = Regex.Replace(strInput, "<[^>]*>", String.Empty).Trim();
txtEditorAnswer.Text = strOutput;
txtEditorAnswer.Text = Server.HtmlEncode(txtEditorAnswer.Text);
but as it changes the value in the Database also, so its creating a problem for future. Now I need to change the text after being inserted into the database.
What should I do?
Your use case isn’t clear, but I’ll assume you want the “Tagged” text when the
txtEditorAnswerhas focus, and the “UnTagged” text when focus moves away.In this case, you could attach a property to
txtEditorAnswer, let’s call itRawText.On Init:
On Focus:
On LostFocus:
(Refactor as appropriate).
Or, as @Andomar points out, you could have a second control that is your “preview” of the text being entered into
txtEditorAnswer.