I am trying to add a user input string to a StringBuilder I can then use elsewhere to display the string I'm building. The problem is when a user does a carriage return and I try to append that to the StringBuilder it removes the escape characters and therefore the return.
For example lets say a user enters the following:
Hello, My name is Tom.
When I pull that string from the textbox control and pass it to my method that holds the StringBuilder it looks like this:
Hello,\r\nMy name is Tom.
But once I append it to the StringBuilder it removes all escape characters and becomes this:
Hello,My name is Tom.
This causes the output to be:
Hello,My name is Tom
instead of:
Hello, My name is Tom
This is the method that pulls the user input from the ctrl
protected List<BetweenTagData> BetweenTagDataPull(string ctrlName)
{
List<BetweenTagData> data = new List<BetweenTagData>();
BetweenTagData pullIt = new BetweenTagData();
if (ctrlName == "Label")
{
pullIt.text = TagLabelTxtbxEnterText.Text.ToString();
data.Add(pullIt);
}
return data;
}
This is the method that builds the string using the StringBuilder
static public string TagBetween(List<BetweenTagData> betweenData)
{
StringBuilder betweenString = new StringBuilder();
foreach (BetweenTagData row in betweenData.ToList())
{
if (row.text != "")
{
betweenString.Append(row.text);
}
}
return betweenString.ToString();
}