IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

ASP.NET Discussion :

Centrage de texte dans un bouton


Sujet :

ASP.NET

  1. #1
    Membre habitué Avatar de PatStan17
    Homme Profil pro
    Chef de projet / Développeur
    Inscrit en
    Décembre 2008
    Messages
    307
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Chef de projet / Développeur
    Secteur : Santé

    Informations forums :
    Inscription : Décembre 2008
    Messages : 307
    Points : 155
    Points
    155
    Par défaut Centrage de texte dans un bouton
    Bonjour aux lecteurs

    Context : ASP.NET, C#, BASE SQLSERVEUR

    Je construit dans mon code behind un clavier qui comporte les 22 lettre de l'alphabet afin d'offrir à mes utilisateurs la possibilité de mettre un critére de sélection sur la premier lettre du nom dans une liste de personnes. Les touches de mon clavier sont constituées de boutons , voici le code :


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
        for (int i = 65; i < 78; i++)
            {
     
                Button BtClavier = new Button();
     
                BtClavier.Attributes.Add("onmouseover", "this.style.color='" + ChaineEntree + "'");
                BtClavier.Attributes.Add("onmouseout", "this.style.color='" + ChaineSortie + "'"); ;
     
                BtClavier.ID = Convert.ToChar(i).ToString();
                BtClavier.Style.Add("font-family", "Arial");
                BtClavier.Style.Add("font-weight", "bold");
                BtClavier.Style.Add("width", "20px");
                BtClavier.Style.Add("height", "28px");
                BtClavier.Style.Add("text-decoration", "none");
                BtClavier.Style.Add("font-size", "10px");
                BtClavier.Style.Add("cursor", "pointer");
                BtClavier.Style.Add("text-align", "center");
                BtClavier.Text = Convert.ToChar(i).ToString();
                BtClavier.ToolTip = "Affichage des manifestations dont le nom commence par " + Convert.ToChar(i).ToString();
     
                BtClavier.Click += Clavier_Click;
     
                TableCell Cellule = new TableCell();
                Cellule.ID = "Cell" + i;
                Cellule.Controls.Add(BtClavier);
     
                TblClavier.Rows[0].Cells.Add(Cellule);
            }
     
     
            for (int i = 78; i < 91; i++)
            {
     
                Button BtClavier = new Button();
     
                BtClavier.Attributes.Add("onmouseover", "this.style.color='" + ChaineEntree + "'");
                BtClavier.Attributes.Add("onmouseout", "this.style.color='" + ChaineSortie + "'"); ;
     
                BtClavier.ID = Convert.ToChar(i).ToString();
                BtClavier.Style.Add("font-family", "Arial");
                BtClavier.Style.Add("font-weight", "bold");
                BtClavier.Style.Add("width", "20px");
                BtClavier.Style.Add("height", "28px");
                BtClavier.Style.Add("text-decoration", "none");
                BtClavier.Style.Add("font-size", "11px");
                BtClavier.Style.Add("cursor", "pointer");
                BtClavier.Style.Add("text-align", "center");
                BtClavier.Text = Convert.ToChar(i).ToString();
                BtClavier.ToolTip = "Affichage des manifestations dont le nom commence par " + Convert.ToChar(i).ToString();
     
                BtClavier.Click += Clavier_Click;
     
                TableCell Cellule = new TableCell();
                Cellule.ID = "Cell" + i;
                Cellule.Controls.Add(BtClavier);
     
                TblClavier.Rows[1].Cells.Add(Cellule);
            }

    Tout ça ...ca marche sauf cette ligne :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    BtClavier.Style.Add("text-align", "center");

    Pour IE 7 par de problèmes , le libellé des bouton est aligné mais pour IE 8, Google Chrome et FireFox les libellès sont alignès à droite ....


    Qqn peut 'il me dépatouiller ?


    Merci d'avance


    P.JEAN

  2. #2
    Membre habitué
    Profil pro
    Inscrit en
    Octobre 2006
    Messages
    207
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2006
    Messages : 207
    Points : 191
    Points
    191
    Par défaut
    essaie d'ajouter

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
    ou bien : (dans le web.config)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
       <system.webServer>
          <httpProtocol>
             <customHeaders>
                <clear />
                <add name="X-UA-Compatible" value="IE=EmulateIE7" />
             </customHeaders>
          </httpProtocol> 
       </system.webServer>
    </configuration>
    Forum asp.net

  3. #3
    Membre habitué Avatar de PatStan17
    Homme Profil pro
    Chef de projet / Développeur
    Inscrit en
    Décembre 2008
    Messages
    307
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Chef de projet / Développeur
    Secteur : Santé

    Informations forums :
    Inscription : Décembre 2008
    Messages : 307
    Points : 155
    Points
    155
    Par défaut Merci
    Ca marche pour IE8 et FireFox mais pas pour google Chrome....

    Je vais pas faire la fine bouche ...je me contente de ça pour le moment ...


    Merci pour ton aide stroumfs

    .PJEAN

Discussions similaires

  1. Police de texte dans les boutons
    Par adelsunwind dans le forum IHM
    Réponses: 2
    Dernier message: 20/10/2008, 20h29
  2. Modification d'un texte dans un bouton
    Par atlantis dans le forum ActionScript 3
    Réponses: 3
    Dernier message: 01/04/2008, 14h05
  3. Faire tenir le texte dans un bouton
    Par francoisch dans le forum Balisage (X)HTML et validation W3C
    Réponses: 3
    Dernier message: 04/02/2008, 10h18
  4. [MFC] changement de texte dans un bouton
    Par benjiprog dans le forum MFC
    Réponses: 16
    Dernier message: 12/06/2006, 20h48
  5. Orientation texte dans un bouton
    Par miky_jo dans le forum Composants
    Réponses: 1
    Dernier message: 03/11/2005, 10h34

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo