335 lines
8.5 KiB
C#
335 lines
8.5 KiB
C#
using SteamWare;
|
|
using System;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace CMS_SC.WebUserControls
|
|
{
|
|
public partial class mod_autocompleteShort : System.Web.UI.UserControl
|
|
{
|
|
/// <summary>
|
|
/// evento valore selezionato
|
|
/// </summary>
|
|
public event EventHandler eh_valSelezionato;
|
|
/// <summary>
|
|
/// evento valore selezionato
|
|
/// </summary>
|
|
public event EventHandler eh_reset;
|
|
/// <summary>
|
|
/// segnaposto x casella testuale autocomplete
|
|
/// </summary>
|
|
public string placeholder { get; set; }
|
|
|
|
/// <summary>
|
|
/// UID formattato con "_"
|
|
/// </summary>
|
|
public string uid
|
|
{
|
|
get
|
|
{
|
|
// fix brutale: nelle pagine master c'è un ctl00_ iniziale di troppo...
|
|
return this.UniqueID.Replace("$", "_").Replace("ctl00_", "").Replace("ctl01_", "");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// caricamento pagina
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
defaultVal = "";
|
|
txtSel.Attributes["placeholder"] = placeholder;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// definisce stato hide del controllo
|
|
/// </summary>
|
|
public bool show
|
|
{
|
|
set
|
|
{
|
|
pnlAC.Visible = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// wrapper traduzione
|
|
/// </summary>
|
|
/// <param name="lemma"></param>
|
|
/// <returns></returns>
|
|
public string traduci(object lemma)
|
|
{
|
|
return user_std.UtSn.Traduci(lemma.ToString());
|
|
}
|
|
|
|
protected void txtSel_TextChanged(object sender, EventArgs e)
|
|
{
|
|
if (txtSel.Text.Trim() == "")
|
|
{
|
|
hiddenFieldID.Text = defaultVal;
|
|
_valore = defaultVal;
|
|
}
|
|
if (eh_valSelezionato != null)
|
|
{
|
|
eh_valSelezionato(this, new EventArgs());
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// salvo valore selezionato!
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void hiddenFieldID_TextChanged(object sender, EventArgs e)
|
|
{
|
|
salvaSelezione();
|
|
}
|
|
/// <summary>
|
|
/// valore selezionato dal controllo (RW local)
|
|
/// </summary>
|
|
protected string _valore
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.StringSessionObj(uid + "_sel");
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal(uid + "_sel", value);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// salva evento selezione
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnPost_Click(object sender, EventArgs e)
|
|
{
|
|
salvaSelezione();
|
|
}
|
|
|
|
private void salvaSelezione()
|
|
{
|
|
_valore = hiddenFieldID.Text;
|
|
if (eh_valSelezionato != null)
|
|
{
|
|
eh_valSelezionato(this, new EventArgs());
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// valore (chiave) selezionato dal controllo (R public)
|
|
/// </summary>
|
|
public string valore
|
|
{
|
|
get
|
|
{
|
|
string answ = "";
|
|
try
|
|
{
|
|
answ = hiddenFieldID.Text;
|
|
}
|
|
catch
|
|
{
|
|
answ = txtSel.Text.Trim();
|
|
}
|
|
if (answ == "")
|
|
{
|
|
answ = txtSel.Text.Trim();
|
|
}
|
|
return answ;
|
|
}
|
|
set
|
|
{
|
|
hiddenFieldID.Text = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// label selezionato dal controllo (R public)
|
|
/// </summary>
|
|
public string selezione
|
|
{
|
|
get
|
|
{
|
|
return txtSel.Text;
|
|
}
|
|
set
|
|
{
|
|
txtSel.Text = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// label dell'etichetta di ricerca
|
|
/// </summary>
|
|
public string labelRicerca
|
|
{
|
|
set
|
|
{
|
|
lblField.Text = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// label dell'etichetta di ricerca CON TRADUZIONE
|
|
/// </summary>
|
|
public string labelRicercaTrad
|
|
{
|
|
set
|
|
{
|
|
lblField.Text = traduci(value);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// num minimo caratteri x autocomplete
|
|
/// </summary>
|
|
public Int32 minCharAutocomplete
|
|
{
|
|
get
|
|
{
|
|
return Convert.ToInt32(txtMinCharAutoCom.Text);
|
|
}
|
|
set
|
|
{
|
|
txtMinCharAutoCom.Text = value.ToString();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// path del webservice (compreso metodo)
|
|
/// nb: DI NORMA fornisce risultati nel formato label#valore
|
|
/// </summary>
|
|
public string ServicePath
|
|
{
|
|
get
|
|
{
|
|
return txtServiceUrl.Text;
|
|
}
|
|
set
|
|
{
|
|
txtServiceUrl.Text = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// imposta visibilità della textBox delle chiavi
|
|
/// </summary>
|
|
public bool showKey
|
|
{
|
|
set
|
|
{
|
|
if (!value)
|
|
{
|
|
hiddenFieldID.Width = Unit.Pixel(0);
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// imposta la stringa tooltip
|
|
/// </summary>
|
|
public string toolTip
|
|
{
|
|
set
|
|
{
|
|
txtSel.ToolTip = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// larghezza textbox in unità EM
|
|
/// </summary>
|
|
public int textEmWidht
|
|
{
|
|
set
|
|
{
|
|
txtSel.Width = Unit.Parse(string.Format("{0}em", value));
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// larghezza textbox in unità %
|
|
/// </summary>
|
|
public int textEmPerc
|
|
{
|
|
set
|
|
{
|
|
txtSel.Width = Unit.Parse(string.Format("{0}%", value));
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// imposta il focus sulla textBox
|
|
/// </summary>
|
|
public void setFocus()
|
|
{
|
|
txtSel.Focus();
|
|
}
|
|
/// <summary>
|
|
/// permette di passare altri parametri di contesto al metodo invocato x autocomplete
|
|
/// </summary>
|
|
public string contextKey
|
|
{
|
|
get
|
|
{
|
|
return txtSel.AccessKey;
|
|
}
|
|
set
|
|
{
|
|
txtSel.AccessKey = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// tabIndex del controllo
|
|
/// </summary>
|
|
public short TabIndex
|
|
{
|
|
set
|
|
{
|
|
txtSel.TabIndex = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// valore di default (x reset)
|
|
/// </summary>
|
|
public string defaultVal { get; set; }
|
|
/// <summary>
|
|
/// resetta controllo
|
|
/// </summary>
|
|
public void doReset()
|
|
{
|
|
// resetto selezione e ricerca!
|
|
txtSel.Text = "";
|
|
hiddenFieldID.Text = defaultVal;
|
|
_valore = defaultVal;
|
|
}
|
|
/// <summary>
|
|
/// effettuato reset
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lnkReset_Click(object sender, EventArgs e)
|
|
{
|
|
doReset();
|
|
if (eh_reset != null)
|
|
{
|
|
eh_reset(this, new EventArgs());
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// stile x la label
|
|
/// </summary>
|
|
public Unit labelWidth
|
|
{
|
|
set
|
|
{
|
|
lblField.Width = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// dummy call x indicare selezione...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSearch_Click(object sender, EventArgs e)
|
|
{
|
|
salvaSelezione();
|
|
}
|
|
}
|
|
} |