Reputation: 13
I want to make an MVC View, which shows a string.
The string contains whitespaces (" "
, "/t"
, "/n"
) and I want to show it in format defined in string.
My problem is, that if I return the string as ViewBag
message, all of these whitespaces are lost. Is there any solution to resolve this problem?
Upvotes: 0
Views: 88
Reputation: 2087
A work around, replace \t
with  
and \n
with <br/>
and you could use,
@Html.Raw(ViewBag.Something)
Upvotes: 1
Reputation: 3362
You have two options to achieve this.
use pre htnml tag
or
you have to hard code the space chars into non-breaking white spaces.
hope it will help you to some extent.
Upvotes: 0
Reputation: 50728
Your issue is a web one where the browser ignores extraneous space. You need to convert all space characters to if you want to retain the number of spaces.
Upvotes: 0