HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/TDijk1/erp-apps.eu/wwwroot/ERPApps/ERPWebParts/LiteralViewer.ascx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using CMS.FormControls;
using CMS.GlobalHelper;
using CMS.FormEngine;
using CMS.Helpers;
using CMS.DataEngine;

public partial class ERPApps_ERPWebParts_LiteralViewer : FormEngineUserControl
{
    #region "Properties"

    /// <summary>
    /// Hide control if the value is empty.
    /// </summary>
    public bool HideIfEmpty
    {
        get
        {
            return ValidationHelper.GetBoolean(GetValue("HideIfEmpty"), true);
        }
        set
        {
            SetValue("HideIfEmpty", value);
        }
    }


    /// <summary>
    /// Gets or sets form control value.
    /// </summary>
    public override object Value
    {
        get
        {
            return label.Text;
        }
        set
        {
            if ((FieldInfo != null) && (FieldInfo.DataType == FieldDataType.Decimal))
            {
                label.Text = ValidationHelper.GetString(ValidationHelper.GetDouble(value, 0, "en-us"), null);
            }
            else if ((FieldInfo != null) && (FieldInfo.DataType == FieldDataType.DateTime))
            {
                label.Text = ValidationHelper.GetString(ValidationHelper.GetDateTime(value, DateTimeHelper.ZERO_TIME, "en-us"), null);
            }
            else
            {
                label.Text = ValidationHelper.GetString(value, null);
            }

            if (!DataHelper.IsEmpty(label.Text))
            {
                label.Text = HTMLBefore + LabelText + HTMLHelper.HTMLEncode(label.Text) + HTMLAfter;
            }
            else
            {
                //Visible = false;
                FieldInfo.Visible = false;
                FieldInfo.Properties["controlcssclass"] = "pepa";
            }
        }
    }

    /// <summary>
    /// Custom text displayed before its value.
    /// </summary>
    public string LabelText
    {
        get
        {
            return ValidationHelper.GetString(GetValue("LabelText"), String.Empty);
        }
        set
        {
            SetValue("LabelText", value);
        }
    }

    public string HTMLBefore
    {
        get
        {
            return ValidationHelper.GetString(GetValue("HTMLBefore"), String.Empty);
        }
        set
        {
            SetValue("HTMLBefore", value);
        }
    }

    public string HTMLAfter
    {
        get
        {
            return ValidationHelper.GetString(GetValue("HTMLAfter"), String.Empty);
        }
        set
        {
            SetValue("HTMLAfter", value);
        }
    }

    #endregion

    protected void Page_Load(object sender, EventArgs e)
    {
        ERPApps_ERPWebParts_LiteralViewer control = Form.FieldControls[FieldInfo.Name] as ERPApps_ERPWebParts_LiteralViewer;
        if (control != null && HideIfEmpty && DataHelper.IsEmpty(label.Text))
        {
            // hide control
            control.Parent.Visible = false;
        }
    }
}