Solved

Label replacement in MVC - linefeeds, carraige returns, <br /> replacements.

Posted on 2014-09-30
2
127 Views
Last Modified: 2014-10-19
Hi

I have information from a number of different sources in my database which I would like to display to my user so what I did was I created a query to gather all the information.

To display the information, i did the following:

ViewData.Add("Details",fullname + "<br />" + partner + "<br />" + address + "<br />" + phone + "<br />" +
                cell + "<br /><br /><a href='myhyperlinkpage.aspx?id=" + id + "'>Edit My Details</a>" );

But it is all formatted incorrectly in the page. The <br /> tags show up as text and my link shows up as <a href='myhyperlinkpage.aspx?id=2046d69cfa888888015797'>Edit My Details</a>

How should I be doing this?
0
Comment
Question by:elmbrook
2 Comments
 

Expert Comment

by:Vipul Malani
ID: 40354179
you can return all this field in model and handle at client site to display that field.
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 40354333
Why hard-code the line breaks into your controller code?

In any event, you need to use the @Html.Raw method to dump this out and have it not be encoded by the view engine.

e.g.

@Html.Raw(ViewData["Details"])

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now