0

I would like to create a line break in the status message. This is the code I have tried but it wont create a new Line. I am using the Status Message that is used in Identity in Asp.net Razor.

On the cshtml page

<partial name="Status Message" model="Model.Status Message" /> 

on the same page I added the following to the scripts

 <p style="white-space: pre-line">@Model.StatusMessage</p>

on the .cs page

if(user.WeeklyReminders  != Input.WeeklyReminders)
{
StatusMessage = "Weekly Reminders email Notifications have been changed. \n";
}
StatusMessage += "Sent";

Results is: Weekly Reminders email Notifications have been changed. Sent

I also tried +Enviroment.NewLine(); With the same result.

I want it to be Weekly Reminders email Notifications have been changed.
Sent.

Thanks

cbas007
  • 1
  • 2

1 Answers1

-1

I know of two methods you can try both and see which you understand

StatusMessage = "Weekly Reminders email Notifications have been changed. \x0A";

or just simply try this

StatusMessage = "Weekly Reminders email Notifications have been changed.";
StatusMessage = "\r\n";
StatusMessage = "Sent";
goor.auss
  • 19
  • 5
  • And this makes it render correctly in the resulting HTML for you? – DiplomacyNotWar Oct 14 '21 at 01:51
  • I dont know what you situation is I cannot test it you have to test it for you self – goor.auss Oct 14 '21 at 01:53
  • Also how is `\x0A` different to `\n`? [Aren't they the same thing?](https://rextester.com/QKTB4557). – DiplomacyNotWar Oct 14 '21 at 01:53
  • What does my situation have to do with OP's question? It's OP's question that you're answer is posted on, and OP is using Razor (and the message is therefore being rendered in HTML). – DiplomacyNotWar Oct 14 '21 at 01:53
  • 1
    I tried this and it did not work. The only thing that showed was sent. the StatusMessage = "Weekly Reminders email Notifications have been changed. \x0A"; Showed the message with sent after. – cbas007 Oct 14 '21 at 02:06