Solved

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

Posted on 2014-09-30
2
124 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 74

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
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.

744 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

14 Experts available now in Live!

Get 1:1 Help Now