private static string GetText(BocRenderingContext <IBocTextValue> renderingContext) { var textMode = renderingContext.Control.TextBoxStyle.TextMode; if (textMode == BocTextBoxMode.PasswordNoRender || textMode == BocTextBoxMode.PasswordRenderMasked) { return(new string ((char)9679, 5)); } string text; if (textMode == BocTextBoxMode.MultiLine) { var lines = StringUtility.ParseNewLineSeparatedString(renderingContext.Control.Text ?? ""); text = RenderUtility.JoinLinesWithEncoding(lines); } else { text = HttpUtility.HtmlEncode(renderingContext.Control.Text); } if (string.IsNullOrEmpty(text) && renderingContext.Control.IsDesignMode) { text = c_designModeEmptyLabelContents; // Too long, can't resize in designer to less than the content's width // Label.Text = "[ " + this.GetType().Name + " \"" + this.ID + "\" ]"; } return(text); }
protected override Label GetLabel(BocRenderingContext <IBocMultilineTextValue> renderingContext) { Label label = new Label { ClientIDMode = ClientIDMode.Static }; label.ID = renderingContext.Control.GetValueName(); label.EnableViewState = false; string[] lines = renderingContext.Control.Value; string text = RenderUtility.JoinLinesWithEncoding(lines ?? Enumerable.Empty <string>()); if (string.IsNullOrEmpty(text) && renderingContext.Control.IsDesignMode) { text = c_designModeEmptyLabelContents; // Too long, can't resize in designer to less than the content's width // label.Text = "[ " + this.GetType().Name + " \"" + this.ID + "\" ]"; } label.Text = text; label.Width = Unit.Empty; label.Height = Unit.Empty; label.ApplyStyle(renderingContext.Control.CommonStyle); label.ApplyStyle(renderingContext.Control.LabelStyle); return(label); }
public void JoinLinesWithEncoding_WithMultipleItemsAndRequiringEncoding_ReturnsConcatenatedAndEncodedString() { Assert.That( RenderUtility.JoinLinesWithEncoding(new[] { "Fir<html>st", "Second" }), Is.EqualTo("Fir<html>st<br />Second")); }
public void JoinLinesWithEncoding_WithSingleItemAndRequiringEncoding_ReturnsEncodedString() { Assert.That( RenderUtility.JoinLinesWithEncoding(new[] { "Fir<html>st" }), Is.EqualTo("Fir<html>st")); }
public void JoinLinesWithEncoding_WithMultipleItems_ReturnsConcatenatedString() { Assert.That( RenderUtility.JoinLinesWithEncoding(new[] { "First", "Second" }), Is.EqualTo("First<br />Second")); }
public void JoinLinesWithEncoding_WithSingleItem_ReturnsString() { Assert.That( RenderUtility.JoinLinesWithEncoding(new[] { "First" }), Is.EqualTo("First")); }
public void JoinLinesWithEncoding_WithEmptySequence_ReturnsEmptyString() { Assert.That( RenderUtility.JoinLinesWithEncoding(Enumerable.Empty <string>()), Is.EqualTo("")); }