diff --git a/MP-MAG/WebUserControls/cmp_toggler.ascx b/MP-MAG/WebUserControls/cmp_toggler.ascx new file mode 100644 index 00000000..94202f1d --- /dev/null +++ b/MP-MAG/WebUserControls/cmp_toggler.ascx @@ -0,0 +1,15 @@ +<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="cmp_toggler.ascx.cs" Inherits="MP_MAG.WebUserControls.cmp_toggler" %> + +
+
+ +
+
+ + + +
+
+ +
+
\ No newline at end of file diff --git a/MP-MAG/WebUserControls/cmp_toggler.ascx.cs b/MP-MAG/WebUserControls/cmp_toggler.ascx.cs new file mode 100644 index 00000000..eccefcce --- /dev/null +++ b/MP-MAG/WebUserControls/cmp_toggler.ascx.cs @@ -0,0 +1,181 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace MP_MAG.WebUserControls +{ + public partial class cmp_toggler : System.Web.UI.UserControl + { + #region Public Events + + /// + /// Evento toggle + /// + public event EventHandler ehToggle; + + #endregion Public Events + + #region Public Properties + + /// + /// Classe x toggle OFF + /// + public string classOff + { + get + { + return lbtToggleOff.CssClass; + } + set + { + lbtToggleOff.CssClass = value; + } + } + + /// + /// Classe x toggle ON + /// + public string classOn + { + get + { + return lbtToggleOn.CssClass; + } + set + { + lbtToggleOn.CssClass = value; + } + } + + /// + /// Text x toggle OFF + /// + public string textOff + { + get + { + return lblOff.Text; + } + set + { + lblOff.Text = value; + } + } + + /// + /// Text x toggle ON + /// + public string textOn + { + get + { + return lblOn.Text; + } + set + { + lblOn.Text = value; + } + } + + /// + /// valore toggle + /// + public bool toggleValue + { + get + { + bool answ = false; + bool.TryParse(hfValue.Value, out answ); + return answ; + } + set + { + hfValue.Value = value.ToString(); + fixDisplay(); + if (ehToggle != null) + { + ehToggle(this, new EventArgs()); + } + } + } + + /// + /// Tooltip x toggle OFF + /// + public string tooltipOff + { + get + { + return lbtToggleOff.ToolTip; + } + set + { + lbtToggleOff.ToolTip = value; + } + } + + /// + /// Tooltip x toggle ON + /// + public string tooltipOn + { + get + { + return lbtToggleOn.ToolTip; + } + set + { + lbtToggleOn.ToolTip = value; + } + } + + #endregion Public Properties + + #region Private Methods + + /// + /// sistema visualizzazione + /// + private void fixDisplay() + { + // sistemo buttons & display... + bool doShow = toggleValue; + lbtToggleOn.Visible = doShow; + lbtToggleOff.Visible = !doShow; + lblOn.Visible = doShow; + lblOff.Visible = !doShow; + } + + #endregion Private Methods + + #region Protected Methods + + protected void lbtToggleOff_Click(object sender, EventArgs e) + { + toggleValue = !toggleValue; + } + + protected void lbtToggleOn_Click(object sender, EventArgs e) + { + toggleValue = !toggleValue; + } + + /// + /// caricamento apgina + /// + /// + /// + protected void Page_Load(object sender, EventArgs e) + { + if (!Page.IsPostBack) + { + fixDisplay(); + } + } + + #endregion Protected Methods + } +} \ No newline at end of file diff --git a/MP-MAG/WebUserControls/cmp_toggler.ascx.designer.cs b/MP-MAG/WebUserControls/cmp_toggler.ascx.designer.cs new file mode 100644 index 00000000..91840de3 --- /dev/null +++ b/MP-MAG/WebUserControls/cmp_toggler.ascx.designer.cs @@ -0,0 +1,62 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace MP_MAG.WebUserControls +{ + + + public partial class cmp_toggler + { + + /// + /// lblOff control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label lblOff; + + /// + /// hfValue control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.HiddenField hfValue; + + /// + /// lbtToggleOn control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.LinkButton lbtToggleOn; + + /// + /// lbtToggleOff control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.LinkButton lbtToggleOff; + + /// + /// lblOn control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label lblOn; + } +}