Bonjour,
J'ai un problème avec le placeHolder. J'ai ajouter un placeholder dans la partie design de mon site web.
Au niveau du code c# aspx.cs, j'ai ajouter des textbox dans ce placeHolder.
Dans ma page web j'ai un bouton valider, j'aimerai qu'une fois qu'on clique sur ce bouton je puisse effectuer des controles sur les textbox ajouter.
Le soucis ces qu'une fois que je clique sur le bouton valider, ma fonction de recherches sur les textBox ne fonctionne pas :/.
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
protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                initialsation();
 
            }
            else
            {
                initialsation();
            }            
            affiche();
 
        }
        public void initialsation()
        {            
            nombreChiffre.Text = "Veuillez Taper"+nombreTire+"lettre";
            for (int i = 0; i < nombreTire; i++)
            {
                choixChiffre.ID = "textBoxNombreChoisi" + i;
                choixChiffre.Columns = 1;
                initialisationMasterMindTextBox.Controls.Add(choixChiffre);
                choixChiffre = new TextBox();
            }
        }
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
protected void ButtonValider_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < nombreTire; i++)
            {
                //Label2.Text = "on passe 1";
                TextBox temp = FindControl(("textBoxNombreChoisi" + i.ToString())) as TextBox;
                Label2.Text += temp.ID.ToString();
                if (temp != null)
                {
                    Label2.Text = "on passe 2";
                    if (temp.Text != "")
                    {
                        Label2.Text = "on passe ici";
                        partie.ajout(Convert.ToInt32(temp.Text));
                    }
                }
            }
}
Merci d'avance pour votre aide