Hi
I am concatenating error message like below. I want when Error message gets displayed . should not get displayed in text.
if (String.IsNullOrWhiteSpace(txtBankName.Text))
{
errMessage += "Bank Name is required and cannot Be empty.";
}
Boolean IsValidDescription = Common.CommonFunction.IsAlpha(txtBankName.Text);
if (IsValidDescription == false)
{
errMessage += "Bank Name : Only Alphabets , Space , _ - allowed.";
}
Thanks
Naimish MakwanaPosted Aug 28, 2024, 5:28 AM
Or you can use like this
Or try
Thanks
Ramco RamcoPosted Aug 28, 2024, 5:35 AM
Hi Naimish
It is giving error message : Label does not contain a definition for InnerHtml
Thanks
Jignesh KumarPosted Aug 28, 2024, 5:26 AM
Hello Ramco,
IS there any reason why are you using ? could you please try only
Naimish MakwanaPosted Aug 28, 2024, 5:25 AM
To ensure that the
tags are interpreted as line breaks in the error message rather than being displayed as text, you can use theInnerHtmlproperty of the label instead of theTextproperty. This way, the HTML tags will be rendered correctly.Here’s how you can modify your code:
1. Update the Label Control to Use
InnerHtmlEnsure your label control is set to use
InnerHtml:2. Set the Error Message Using
InnerHtmlIn your code-behind, set the
InnerHtmlproperty of the label:Explanation
lblErrorMessage.Text = hfErrorMessage.Value;: This line sets the text of the label, which will display the HTML tags as plain text.lblErrorMessage.InnerHtml = errMessage;: This line sets the inner HTML of the label, which will render the HTML tags correctly as line breaks.By using
InnerHtml, the
tags will be rendered as line breaks in the error message, ensuring the message is displayed correctly within the modal.Thanks