0

I have a textbox(along with many other textboxes) in my cshtml view, where the user can enter some random texts(which can me multiline in nature) and save it in database. Once the data is saved successfully, the user can view the saved data using a "View Stats" button. On click of this button, all the saved data will be loaded in read-only mode in respective labels. The problem here is, the multiline texts that the user entered, is displayed in single line in the label. But when the user tries to edit the record(where the data is disaplyed in a textbox) the data is shown as multiline. How can I achieve the same functionality in view mode where I wish to display the multiline texts in label.

Below is my textbox:

@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;" });
     }
  }
}

Below is my Label:

@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>
    }
  }
}

I hide and show the panels based on edit or view mode. Could you please help me display text in label as multiline.

Arpita Dutta
  • 291
  • 7
  • 19

1 Answers1

0

Instead of using Label You can use textarea with hidden option so it useful to you for read only feature

overflow:hidden; or overflow:visible;

so:

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

It would be easier to read your code if you used CSS though.

I'm not really sure what you're trying to do then, width:220px; made the text break for me. This also worked, and I believe it better matches what I think you're trying to do:

#lbl{           
    max-width:220px;
    height:auto;
}
Abi
  • 724
  • 6
  • 22