0

In above MVC 3.0 View one string variable include the html but not working

 string address = "-";
                if (Model.Landmark != null)
                {
                    address = Model.FlatBuildingName + " " + Model.RoadStreet + " " + Model.Landmark +"</br> "+ Model.Pincode + " " + Model.Villagecity ;
                }

include the html tag but out show the

Out Put

FlatBuildingName RoadStreet Landmark</br>PincodeVillagecity
3
  • It is definitely possible as you are already doing that.. but if you are asking if it makes sense, I don't think so. Seems like a waste to make all those properties only to concatenate into one property. Commented Mar 26, 2013 at 7:29
  • And if I completely misunderstood your question, edit your question to make sense. Commented Mar 26, 2013 at 7:30
  • Correct </br> to <br /> and then go with the suggestion provided by @webdeveloper Commented Mar 26, 2013 at 8:01

1 Answer 1

1

Try HtmlHelper.Raw Method to write your string to the html document. Like this:

@Html.Raw(address)

But you should check and sanitize html with your own, because if your string will contain scripts they will be executed in browser.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.