diff --git a/GMW/WebUserControls/mod_autocomplete.ascx b/GMW/WebUserControls/mod_autocomplete.ascx new file mode 100644 index 00000000..cccb29d1 --- /dev/null +++ b/GMW/WebUserControls/mod_autocomplete.ascx @@ -0,0 +1,105 @@ +<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="mod_autocomplete.ascx.cs" Inherits="GMW.WebUserControls.mod_autocomplete" %> +<%if (false) + { %> + + +<%} %> + + +<%--controlli "principali"--%> +
+ + + + + + + <%--controlli "accessori"--%> + + + + + +
+ + diff --git a/GMW/WebUserControls/mod_autocomplete.ascx.cs b/GMW/WebUserControls/mod_autocomplete.ascx.cs new file mode 100644 index 00000000..1679e776 --- /dev/null +++ b/GMW/WebUserControls/mod_autocomplete.ascx.cs @@ -0,0 +1,270 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using SteamWare; + +namespace GMW.WebUserControls +{ + public partial class mod_autocomplete : System.Web.UI.UserControl + { + /// + /// evento valore selezionato + /// + public event EventHandler eh_valSelezionato; + /// + /// evento valore selezionato + /// + public event EventHandler eh_reset; + /// + /// segnaposto x casella testuale autocomplete + /// + public string placeholder { get; set; } + + /// + /// UID formattato con "_" + /// + public string uid + { + get + { + // fix brutale: nelle pagine master c'è un ctl00_ iniziale di troppo... + return this.UniqueID.Replace("$", "_").Replace("ctl00_", "").Replace("ctl01_", ""); + } + } + + /// + /// caricamento pagina + /// + /// + /// + protected void Page_Load(object sender, EventArgs e) + { + if (!Page.IsPostBack) + { + defaultVal = ""; + txtSelezione.Attributes["placeholder"] = placeholder; + } + } + + protected void txtSelezione_TextChanged(object sender, EventArgs e) + { + if (txtSelezione.Text.Trim() == "") + { + hiddenFieldID.Text = defaultVal; + _valore = defaultVal; + if (eh_valSelezionato != null) + { + eh_valSelezionato(this, new EventArgs()); + } + } + } + + /// + /// salvo valore selezionato! + /// + /// + /// + protected void hiddenFieldID_TextChanged(object sender, EventArgs e) + { + _valore = hiddenFieldID.Text; + if (eh_valSelezionato != null) + { + eh_valSelezionato(this, new EventArgs()); + } + } + /// + /// valore selezionato dal controllo (RW local) + /// + protected string _valore + { + get + { + return memLayer.ML.StringSessionObj(uid + "_sel"); + } + set + { + memLayer.ML.setSessionVal(uid + "_sel", value); + } + } + /// + /// salva evento selezione + /// + /// + /// + protected void btnPost_Click(object sender, EventArgs e) + { + _valore = hiddenFieldID.Text; + if (eh_valSelezionato != null) + { + eh_valSelezionato(this, new EventArgs()); + } + } + + /// + /// valore (chiave) selezionato dal controllo (R public) + /// + public string valore + { + get + { + return hiddenFieldID.Text; + } + set + { + hiddenFieldID.Text = value; + } + } + /// + /// label selezionato dal controllo (R public) + /// + public string selezione + { + get + { + return txtSelezione.Text; + } + set + { + txtSelezione.Text = value; + } + } + /// + /// label dell'etichetta di ricerca + /// + public string labelRicerca + { + set + { + lblField.Text = value; + } + } + /// + /// num minimo caratteri x autocomplete + /// + public Int32 minCharAutocomplete + { + get + { + return Convert.ToInt32(txtMinCharAutoCom.Text); + } + set + { + txtMinCharAutoCom.Text = value.ToString(); + } + } + /// + /// path del webservice (compreso metodo) + /// nb: DI NORMA fornisce risultati nel formato label#valore + /// + public string ServicePath + { + get + { + return txtServiceUrl.Text; + } + set + { + txtServiceUrl.Text = value; + } + } + /// + /// imposta visibilità della textBox delle chiavi + /// + public bool showKey + { + set + { + if (!value) + { + hiddenFieldID.Width = Unit.Pixel(0); + } + } + } + /// + /// imposta la stringa tooltip + /// + public string toolTip + { + set + { + txtSelezione.ToolTip = value; + } + } + + /// + /// larghezza textbox in unità EM + /// + public int textEmWidht + { + set + { + txtSelezione.Width = Unit.Parse(string.Format("{0}em", value)); + } + } + /// + /// larghezza textbox in unità % + /// + public int textEmPerc + { + set + { + txtSelezione.Width = Unit.Parse(string.Format("{0}%", value)); + } + } + /// + /// imposta il focus sulla textBox + /// + public void setFocus() + { + txtSelezione.Focus(); + } + /// + /// permette di passare altri parametri di contesto al metodo invocato x autocomplete + /// + public string contextKey + { + get + { + return txtSelezione.AccessKey; + } + set + { + txtSelezione.AccessKey = value; + } + } + /// + /// tabIndex del controllo + /// + public short TabIndex + { + set + { + txtSelezione.TabIndex = value; + } + } + /// + /// valore di default (x reset) + /// + public string defaultVal { get; set; } + + /// + /// effettuato reset + /// + /// + /// + protected void lnkReset_Click(object sender, EventArgs e) + { + // resetto selezione e ricerca! + txtSelezione.Text = ""; + hiddenFieldID.Text = defaultVal; + _valore = defaultVal; + if (eh_reset != null) + { + eh_reset(this, new EventArgs()); + } + } + } +} \ No newline at end of file diff --git a/GMW/WebUserControls/mod_autocomplete.ascx.designer.cs b/GMW/WebUserControls/mod_autocomplete.ascx.designer.cs new file mode 100644 index 00000000..af0ea9ac --- /dev/null +++ b/GMW/WebUserControls/mod_autocomplete.ascx.designer.cs @@ -0,0 +1,96 @@ +//------------------------------------------------------------------------------ +// +// 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 GMW.WebUserControls { + + + public partial class mod_autocomplete { + + /// + /// BundleReference1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::Microsoft.AspNet.Web.Optimization.WebForms.BundleReference BundleReference1; + + /// + /// BundleReference2 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::Microsoft.AspNet.Web.Optimization.WebForms.BundleReference BundleReference2; + + /// + /// lblField control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label lblField; + + /// + /// btnPost control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button btnPost; + + /// + /// txtSelezione control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtSelezione; + + /// + /// hiddenFieldID control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox hiddenFieldID; + + /// + /// txtMinCharAutoCom control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtMinCharAutoCom; + + /// + /// txtServiceUrl control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtServiceUrl; + + /// + /// lnkReset control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.LinkButton lnkReset; + } +}