using System; using System.Web.UI; namespace NKC_WF.WebUserControls { public partial class cmp_barcode : BaseUserControl { protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { resetMessage(); } else if (string.IsNullOrEmpty(inputAcquired)) { checkRaiseEv(); } } protected string lastCmd { get { return hfLastCmd.Value; } set { hfLastCmd.Value = value; } } public void resetMessage() { lblOutput.Visible = false; lblOutput.Text = ""; } protected void txtBarcode_TextChanged(object sender, EventArgs e) { checkRaiseEv(); } private void checkRaiseEv() { if (lastCmd != inputAcquired) { // alzo evento SOLO SE il nuovo valore è diverso da null... lastCmd = inputAcquired; if (!string.IsNullOrEmpty(inputAcquired)) { raiseEvent(); } } else { if (string.IsNullOrEmpty(lastCmd)) { resetMessage(); } } txtBarcode.Focus(); } /// /// Valore acquisito in lettura barcode /// public string inputAcquired { get { return txtBarcode.Text.Trim(); } set { txtBarcode.Text = ""; } } /// /// Reset input del barcode SENZA generare evento... /// /// public void resetInput() { inputAcquired = ""; txtBarcode.Focus(); } /// /// Gestione output da mostrare (opzionale /// /// /// public void showOutput(string cssClass, string messaggio) { // In primis: mostro qualcosa SOLO SE ho del testo lblOutput.Visible = !string.IsNullOrEmpty(messaggio); lblOutput.Text = messaggio; lblOutput.Attributes.Remove("class"); lblOutput.Attributes.Add("class", cssClass); } } }