protected void AddError(Table table, string imageName, string message, string testTag = "ErrorInfo")
{
TableRow errorRow = new TableRow();
table.Rows.Add(errorRow);
var lblCell = new TableCell();
if (!string.IsNullOrEmpty(imageName))
{
Image image = new Image()
{
ImageUrl = ImageLoader.Instance.GetImageInfo(imageName).ImageUrl
};
lblCell.Controls.Add(image);
}
lblCell.Attributes["id"] = ClientID + "_" + testTag;
lblCell.Attributes[EasyTestTagHelper.TestField] = testTag;
lblCell.Attributes[EasyTestTagHelper.TestControlClassName] = JSLabelTestControl.ClassName;
Literal label = new Literal();
lblCell.Controls.Add(label);
errorRow.Cells.Add(lblCell);
string formattedMessage = System.Web.HttpUtility.HtmlEncode(message.Trim());
if (formattedMessage.Length > 2 && formattedMessage.Substring(0, 2) == "- ")
formattedMessage = " " + formattedMessage.Substring(2, formattedMessage.Length - 2);
string[] lines = formattedMessage.Split('\n');
formattedMessage = string.Join("<br>", lines);
label.Text = formattedMessage;
}