How to put strings in asp.net resource files
I have a label on an asp.net page that gets its text from a global resource file something like this:
<asp:Label ID="Label1" runat="server" Text="<%$ Resources:MyResource, MyString %>" />
The resource string for MyString contains text with a linebreak character, for example:
line1
string2
When the label is displayed I get the following html
<span id="Label1">line1line2</span>
but instead I want it to display as
<span id="Label1">line1<br/>line2</span>
Is there a standard way to do this without putting br tags in the resource file or by manually replacing the text in the resource string?
+2
MarioH
source
to share
2 answers
Resources are just plain text, you will need to process them after pulling data from the resource file to change the newlines to <br/>
.
+2
Jan Jongboom
source
to share
The standard way is to place tags <br />
in the text.
+2
Deniz dogan
source
to share