begin process at 2012 02 14 05:32:37
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

ASP.Net

 > BOUTON QUI EMPECHE LE MULTI CLIC AVANT LA FIN DU TRAITEMENT. DISABLE DOUBLE POSTBACK

BOUTON QUI EMPECHE LE MULTI CLIC AVANT LA FIN DU TRAITEMENT. DISABLE DOUBLE POSTBACK


 Information sur la source

Note :
Aucune note
Catégorie :ASP.Net Source .NET ( DotNet ) Classé sous :disable postback, multi postback, plusieurs clic, interdire doubleclic Niveau :Initié Date de création :11/10/2009 Date de mise à jour :13/10/2009 12:19:29 Vu / téléchargé :5 341 / 221

Auteur : fredzool

Ecrire un message privé
Site perso
Commentaire sur cette source (0)
Ajouter un commentaire et/ou une note

 Description

lorsqu'un utilisateur clique plusieurs fois sur un bouton, cela entraine plusieurs postback

si l'on fait un traitement long dans le post back puis un redirecte, il peut y avoir des problemes si l on onsere des donnees en base

grace a ce bouton, il est impossible de renvoye un postback tant que le premier n est pas finit

il y a la possibilite de definir s il y a une validation a attendre avec un validator

Source

  • namespace WebControlLibrary1
  • {
  • using System;
  • using System.ComponentModel;
  • using System.Text;
  • using System.Web.UI;
  • using System.Web.UI.WebControls;
  • /// <summary>
  • /// Button who disable double post back
  • /// </summary>
  • [DefaultProperty("Text")]
  • [ToolboxData("<{0}:CustomButton runat=server></{0}:CustomButton>")]
  • public class CustomButton : Button
  • {
  • private bool _useValidation = false;
  • private string _waitingText = "Patientez svp...";
  • /// <summary>
  • /// Gets or sets a value indicating whether [use validation].
  • /// </summary>
  • /// <value><c>true</c> if [use validation]; otherwise, <c>false</c>.</value>
  • [Category("Appearance")]
  • [Browsable(true)]
  • public bool UseValidation
  • {
  • get { return _useValidation; }
  • set {_useValidation = value;}
  • }
  • [Category("Appearance")]
  • [Browsable(true)]
  • public string WaitingText
  • {
  • get { return _waitingText; }
  • set { _waitingText = value; }
  • }
  • /// <summary>
  • /// Raises the <see cref="E:System.Web.UI.Control.Load"/> event.
  • /// </summary>
  • /// <param name="e">The <see cref="T:System.EventArgs"/> object that contains the event data.</param>
  • protected override void OnLoad(EventArgs e)
  • {
  • StringBuilder sbValid = new StringBuilder();
  • if (_useValidation)
  • {
  • sbValid.Append("if (typeof(Page_ClientValidate) == 'function') { ");
  • sbValid.Append("if (Page_ClientValidate() == false) { return false; }} ");
  • }
  • sbValid.Append(string.Format("this.value = '{0}';", _waitingText));
  • sbValid.Append("this.disabled = true;");
  • sbValid.Append(Page.ClientScript.GetPostBackEventReference(this, null).ToString());
  • sbValid.Append(";");
  • Attributes.Add("onclick", sbValid.ToString());
  • base.OnLoad(e);
  • }
  • }
  • }
namespace WebControlLibrary1
{
    using System;
    using System.ComponentModel;
    using System.Text;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    /// <summary>
    /// Button who disable double post back
    /// </summary>
    [DefaultProperty("Text")]
    [ToolboxData("<{0}:CustomButton runat=server></{0}:CustomButton>")]
    public class CustomButton : Button 
    {
        private bool _useValidation = false;
        private string _waitingText = "Patientez svp...";

        /// <summary>
        /// Gets or sets a value indicating whether [use validation].
        /// </summary>
        /// <value><c>true</c> if [use validation]; otherwise, <c>false</c>.</value>
        [Category("Appearance")]
        [Browsable(true)]
        public bool UseValidation 
        {
            get { return _useValidation; } 
            set {_useValidation = value;} 
        }

        [Category("Appearance")]
        [Browsable(true)]
        public string WaitingText
        {
            get { return _waitingText; }
            set { _waitingText = value; }
        }

        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load"/> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs"/> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            StringBuilder sbValid = new StringBuilder();
            if (_useValidation)
            {
                sbValid.Append("if (typeof(Page_ClientValidate) == 'function') { ");
                sbValid.Append("if (Page_ClientValidate() == false) { return false; }} ");
            }

            sbValid.Append(string.Format("this.value = '{0}';", _waitingText));
            sbValid.Append("this.disabled = true;");
            sbValid.Append(Page.ClientScript.GetPostBackEventReference(this, null).ToString());
            sbValid.Append(";");

            Attributes.Add("onclick", sbValid.ToString());
            base.OnLoad(e);
        }
    }
}


 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip


 Historique

13 octobre 2009 12:19:34 :
changement du titre

 Sources du même auteur

Source avec Zip CHECKED DROPDOWNLIST
Source avec Zip Source avec une capture Source .NET (Dotnet) GRIDVIEW WITH TREEVIEW AND CALLBACK
Source avec Zip APPELLER UN WEBSERVICE DEPUIS JAVASCRIPT
Source avec Zip Source .NET (Dotnet) MONEY TEXTBOX WITH EMBEDED JAVASCRIPT
Source avec Zip Source .NET (Dotnet) CUSTOM DATEPIKER DÉRIVANT DE COMPOSITECONTROL

 Sources de la même categorie

Source avec Zip Source .NET (Dotnet) GUESTBOOK AVEC GRIDVIEW par DanMor498
Source avec Zip CHECKED DROPDOWNLIST par fredzool
Source avec Zip Source avec une capture Source .NET (Dotnet) GRIDVIEW WITH TREEVIEW AND CALLBACK par fredzool
Source avec Zip APPELLER UN WEBSERVICE DEPUIS JAVASCRIPT par fredzool
Source avec Zip Source .NET (Dotnet) MONEY TEXTBOX WITH EMBEDED JAVASCRIPT par fredzool

Commentaires et avis

Aucun commentaire pour le moment.

 Ajouter un commentaire




Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

Photothèque

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,640 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales