Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-09-30
2
Medium Priority
?
143 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

721 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