A. Gladkiy
A. Gladkiy

Reputation: 3450

.net razor make multiline label

I have the following label:

@Html.LabelFor(m => m.Data, "text1 / text2", null)

I want to move text2 on new line.

@Html.LabelFor(m => m.Data, "text1 /\r\n text2", null)

and

@Html.LabelFor(m => m.Data, "text1 /<br/> text2", null)

didn't help me.

Is there way to do that?

Upvotes: 1

Views: 719

Answers (3)

Martin D.
Martin D.

Reputation: 2090

Yes it's possible using the tag helpers:

@Html.Raw(HttpUtility.HtmlDecode(Html.LabelFor(m => m.Data, "text1 / <br />text2", null).ToString()))

Upvotes: 1

Dimitri
Dimitri

Reputation: 1271

You can use a TextAreaFor and set a readonly property to it:

<%=Html.TextAreaFor(m => m.Data,   new { rows="1", style = "border: 0 none white; background-color:#EEF3FB; color: #424242; width:280px; margin:3px;", @readonly = "readonly", @disabled = "disabled", })%>

Got it from here

Upvotes: 0

Matcy
Matcy

Reputation: 23

Try the following as the Raw keyword will allow you to embed html:

@Html.Raw(Html.LabelFor(m => m.Data, "text1 /<br/> text2", null))

Upvotes: 0

Related Questions