.net剃刀制作多行标签

时间:2019-04-05 10:07:16

标签: c# asp.net-mvc razor

我有以下标签:

public void sendNotif(){

    Intent resultIntent = new Intent(this, TimerActivity.class);


    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);


    not = new NotificationCompat.Builder(this,Notif.CHANNEL_ID)
            .setSmallIcon(R.drawable.curved_shape)
            .setContentTitle("Productivity Timer")
            .setContentText("Your Timer is Running")
            .setPriority(NotificationCompat.PRIORITY_HIGH)
            .setCategory(NotificationCompat.CATEGORY_PROGRESS)
            .setOngoing(true)
            .setContentIntent(pendingIntent)
            .build();

    notificationManager.notify(1,not);

}

我想在新行上移动@Html.LabelFor(m => m.Data, "text1 / text2", null)

text2

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

没有帮助我。

有办法吗?

3 个答案:

答案 0 :(得分:1)

是的,可以使用标签助手:

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

答案 1 :(得分:0)

尝试以下操作,因为Raw关键字将允许您嵌入html:

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

答案 2 :(得分:0)

您可以使用TextAreaFor并将其设置为只读属性:

<%=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