Solved

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

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

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…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

623 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