使用jquery

时间:2017-01-16 05:55:08

标签: jquery razor kendo-ui label multiline

我的cshtml视图中有一个文本框(以及许多其他文本框),用户可以在其中输入一些随机文本(本质上可以是多行文本)并将其保存在数据库中。成功保存数据后,用户可以使用"查看统计信息"查看保存的数据。按钮。单击此按钮,所有已保存的数据将以只读模式加载到相应的标签中。这里的问题是,用户输入的多行文本在标签中以单行显示。但是当用户尝试编辑记录(数据在文本框中被删除)时,数据显示为多行。如何在视图模式下实现相同的功能,我希望在标签中显示多行文本。

下面是我的文本框:

@using (Html.BeginInnerPanel(true, new { style = "width:100%;", id =      "pnlRemarks" }, "", false))
{
  using (Html.BeginInnerPanelBody())
  {
     using (Html.BeginFieldWrap("Remarks", "", new { style = "width:100%"   }))
    {
         @Html.TextArea("txtRemarks", "", new { style = "width:99%;height:80px; text-transform: uppercase;" });
     }
  }
}

以下是我的标签:

@using (Html.BeginInnerPanel(true, new { style = "width:100%; display:none;", id = "pnlRemarksV" }, "", false))
 {
    using (Html.BeginInnerPanelBody())
    {
       using (Html.BeginFieldWrap("Remarks", "", new { style = "width:100%"    }))
    {
       <label id="lblViewRemarks" style = "font-weight:bold"></label>
    }
  }
}

我隐藏并根据编辑或查看模式显示面板。你能帮我把标签上的文字显示为多行吗?

1 个答案:

答案 0 :(得分:0)

而不是使用Label您可以将textarea与隐藏选项一起使用,因此对于只读功能

非常有用

溢出:隐藏;或溢出:可见;

这样:

<textarea id="txt" type="text" style="position:absolute; top:200px; left:170px; overflow:hidden;"></textarea>

如果使用CSS,那么阅读代码会更容易。

我不确定你当时要做什么,宽度:220px;让文章休息了。这也有效,我相信它更符合我认为你想要做的事情:

#lbl{           
    max-width:220px;
    height:auto;
}