diff --git a/src/pixelmedia.sitecorecms.controls/Controls/MultilineTextRenderer.cs b/src/pixelmedia.sitecorecms.controls/Controls/MultilineTextRenderer.cs new file mode 100644 index 0000000..672d609 --- /dev/null +++ b/src/pixelmedia.sitecorecms.controls/Controls/MultilineTextRenderer.cs @@ -0,0 +1,61 @@ +using System; +using System.Web.UI; +using Sitecore.Web.UI.WebControls; + +namespace PixelMEDIA.SitecoreCMS.Controls.Controls +{ + /// + /// Control to render mult-line text with option to stop Sitecore from replacing line feeds with + /// break tags. Needed when outputting javascript. + /// + public class MultilineTextRenderer : FieldRenderer + { + private bool _addScriptTags = false; + private bool _disableBreakTags = false; + + public bool AddScriptTags + { + get { return _addScriptTags; } + set { _addScriptTags = value; } + } + + public bool DisableBreakTags + { + get { return _disableBreakTags; } + set { _disableBreakTags = value; } + } + + protected override void Render(System.Web.UI.HtmlTextWriter output) + { + if (Item == null) + { + Item = this.GetItem(); + } + if (this.Item != null) + { + var dataField = this.Item.Fields[this.FieldName]; + if (null == dataField) { return; } + var content = dataField.Value; + if (!String.IsNullOrEmpty(content)) + { + if (AddScriptTags) + { + output.RenderBeginTag(HtmlTextWriterTag.Script); + } + if (DisableBreakTags) + { + output.Write(dataField.Value); + } + else + { + base.DoRender(output); + } + if (AddScriptTags) + { + output.RenderEndTag(); + } + } + } + } + } +} diff --git a/src/pixelmedia.sitecorecms.controls/PixelMEDIA.SitecoreCMS.Controls.csproj b/src/pixelmedia.sitecorecms.controls/PixelMEDIA.SitecoreCMS.Controls.csproj index 5a2b481..67d7d96 100644 --- a/src/pixelmedia.sitecorecms.controls/PixelMEDIA.SitecoreCMS.Controls.csproj +++ b/src/pixelmedia.sitecorecms.controls/PixelMEDIA.SitecoreCMS.Controls.csproj @@ -73,9 +73,8 @@ ASPXCodeBehind - - + diff --git a/src/pixelmedia.sitecorecms.controls/Properties/AssemblyInfo.cs b/src/pixelmedia.sitecorecms.controls/Properties/AssemblyInfo.cs index e110d7a..74b7c65 100644 --- a/src/pixelmedia.sitecorecms.controls/Properties/AssemblyInfo.cs +++ b/src/pixelmedia.sitecorecms.controls/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.1.4")] -[assembly: AssemblyFileVersion("1.0.1.4")] +[assembly: AssemblyVersion("1.0.1.6")] +[assembly: AssemblyFileVersion("1.0.1.6")]