Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: ASP.NET
Expertise: Advanced
May 18, 2009

WEBINAR:

On-Demand

Full Text Search: The Key to Better Natural Language Queries for NoSQL in Node.js


Displaying Embedded Newline Characters from ASP.NET Resource Files

When an ASP.NET resource file includes newline characters (\n) as part of a string value, the embedded newlines don't show up correctly on the client side. The solution is to use the special defined character Environment.NewLine in your server-side code. The example below is in VB, but the same approach works in C#:
Dim resReader As ResourceReader = Nothing
Dim dicEnumerator As IDictionaryEnumerator = Nothing
Dim keyValuePair As StringBuilder

resReader = New ResourceReader(path)
dicEnumerator = resReader.GetEnumerator()

While dicEnumerator.MoveNext()
' Environment.NewLine is the new line char most appropriate for the 'environment
keyValuePair.Append(dicEnumerator.Key + "=" + _
   dicEnumerator.Value.ToString().Replace("\n", Environment.NewLine))
End While
The preceding code replaces any \n characters embedded in the resource string with the Environment.NewLine character.
Deepankar Sinha
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date