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);
        }
예제 #3
0
 public void JoinLinesWithEncoding_WithMultipleItemsAndRequiringEncoding_ReturnsConcatenatedAndEncodedString()
 {
     Assert.That(
         RenderUtility.JoinLinesWithEncoding(new[] { "Fir<html>st", "Second" }),
         Is.EqualTo("Fir&lt;html&gt;st<br />Second"));
 }
예제 #4
0
 public void JoinLinesWithEncoding_WithSingleItemAndRequiringEncoding_ReturnsEncodedString()
 {
     Assert.That(
         RenderUtility.JoinLinesWithEncoding(new[] { "Fir<html>st" }),
         Is.EqualTo("Fir&lt;html&gt;st"));
 }
예제 #5
0
 public void JoinLinesWithEncoding_WithMultipleItems_ReturnsConcatenatedString()
 {
     Assert.That(
         RenderUtility.JoinLinesWithEncoding(new[] { "First", "Second" }),
         Is.EqualTo("First<br />Second"));
 }
예제 #6
0
 public void JoinLinesWithEncoding_WithSingleItem_ReturnsString()
 {
     Assert.That(
         RenderUtility.JoinLinesWithEncoding(new[] { "First" }),
         Is.EqualTo("First"));
 }
예제 #7
0
 public void JoinLinesWithEncoding_WithEmptySequence_ReturnsEmptyString()
 {
     Assert.That(
         RenderUtility.JoinLinesWithEncoding(Enumerable.Empty <string>()),
         Is.EqualTo(""));
 }