asp.net | Label Accepts multi-line content

CSS

.lbltxt {
    display: inline-block;
    border: 1px #cacaca solid;
    width: 100%;
    padding: 5px;
    background: #e2e2e2;
    min-height: 30px;
    border-bottom: 1px solid #fff;
    border-left: 1px solid #fff;
}

Label

<asp:Label runat="server" ID="lbl" OnPreRender="lbl_comments_PreRender" Text='<%# Bind("Comments") %>' CssClass="lbltxt" />

PreRender

 Protected Sub lbl_PreRender(sender As Object, e As EventArgs)
        Dim lbl As Label = sender
        lbl.Text = Replace(lbl.Text, Chr(13) + Chr(10), "<br/>")
    End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *