Bonjour à tous,

Je travaille dans mon exemple avec 3 controles slider tous ont une valeur maximum de 100 % et je veux programmer chacun de ces controles que lorseque je glisse l'un des 3 à la valeur 50% les deux autres auront comme valeur 25% et 25% pour que la somme totale soit de 100%. donc j'ai débuter à les programmés voici les codes de ces 3 controles.

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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
protected void TextBox_TextChanged(object sender, EventArgs e)
    {
 
 
        float a = 0;
        float c = 100;
        float b = 0;
        float j = 0;
        //float d;
 
        a = float.Parse(tau.Text.ToString());
 
        if (float.Parse(tau.Text.ToString()) != 0)
        {
            b = c - a;
            j = (b / (float)2);
 
            per.Text = Convert.ToString(j);
            dyn.Text = Convert.ToString(j);
        }
        if (float.Parse(tau.Text.ToString()) == 0)
        {
            per.Text = "50";
            dyn.Text = "50";
 
        }
        if (a == 100)
        {
            per.Text = "0";
            dyn.Text = "0";
 
        }
          }
    protected void TextBox1_TextChanged(object sender, EventArgs e)
    {
 
 
        float a1;
        float c1 = 100;
        float b1;
        float j1 = 0;
        //float d;
 
        a1 = float.Parse(per.Text.ToString());
 
        if (a1 != 0)
        {
            b1 = c1 - a1;
            j1 = (b1 / (float)2);
 
            tau.Text = Convert.ToString(j1);
            dyn.Text = Convert.ToString(j1);
        }
        if (a1 == 0)
        {
            tau.Text = "50";
            dyn.Text = "50";
 
        }
        if (a1 == 100)
        {
            tau.Text = "0";
            dyn.Text = "0";
 
        }
 
 
 
    }
    protected void TextBox2_TextChanged(object sender, EventArgs e)
    {
 
 
        float a2;
        float c2 = 100;
        float b2;
        float j2 = 0;
 
 
        a2 = float.Parse(dyn.Text.ToString());
 
        if (a2 != 0)
        {
            b2 = c2 - a2;
            j2 = (b2 / (float)2);
 
            tau.Text = Convert.ToString(j2);
            per.Text = Convert.ToString(j2);
        }
        if (a2 == 0)
        {
            per.Text = "50";
            tau.Text = "50";
 
        }
        if (a2 == 100)
        {
            per.Text = "0";
            tau.Text = "0";
 
        }
 
    }
Sachant que tau est le textbox de slider1,per est le textbox de slider2,dyn est le textbox de slider3.

Problème: parfois lorseque je glisse l'un des 3 sliders vers une valeur et lorseque la page se charge il me retourne autre valeur,que je ne sais pas d'ou elle vienne?

Merci d'avances