Evenement qui ne marche qu'une seule fois

cs_jimmy28 Messages postés 88 Date d'inscription vendredi 23 juillet 2004 Statut Membre Dernière intervention 18 avril 2008 - 13 sept. 2007 à 20:44
cs_jimmy28 Messages postés 88 Date d'inscription vendredi 23 juillet 2004 Statut Membre Dernière intervention 18 avril 2008 - 14 sept. 2007 à 15:39
Salut.

Dans ma page web, je crée au load une table avec des boutons dynamiquement qui appellent une fonction btn_click().

En fait, lorsque je cliques sur un des boutons, il me refait le load(), suivi de la fonction btn_click. Donc ca marche.

Apres le second load(), j'ai bien sur ma table qui se reconstruit avec mes boutons, mais là, si je clique sur un des boutons, la page me refait le load(), mais ne lance pas la fonction clik().

Avez vous une idée???????

merci d'avance

2 réponses

yanis7518 Messages postés 283 Date d'inscription mercredi 7 décembre 2005 Statut Membre Dernière intervention 9 juillet 2010 3
14 sept. 2007 à 13:50
est ce qu'il serait possible de voir ton code???
0
cs_jimmy28 Messages postés 88 Date d'inscription vendredi 23 juillet 2004 Statut Membre Dernière intervention 18 avril 2008
14 sept. 2007 à 15:39
voici mon code un petit peu abrégé :

Protected
Sub Page_Load(
ByVal sender
As
Object,
ByVal e
As System.EventArgs)
Handles
Me.Load

If Session(
"sql") <>
""
Thenconnexion()

table = recup_requete(Session(

"SQL"))deconnexion()

construction_table()

End
If

End
Sub

Public
Sub construction_table()Table1.Rows.Clear()

'*************************************************************************************************************************************

'Fabrication de la table contenant la liste des annonces correspondante aux criteres de selection

'*************************************************************************************************************************************Table1.Caption = table.Rows.Count &

" annonce(s) correspond(ent) … vos critŠres"

'on affiche le titre des colonnes
Dim col(5, 2)col(0, 0) "Nø"col(0, 1)
"numero"col(1, 0) "Titre"col(1, 1)

"titre"

Dim Ligne
As
New TableRowLigne.Font.Size = 12
Ligne.Font.Name "Courier New"Ligne.Font.Underline

TrueLigne.Font.Bold =

False

For a
As
Integer = 0
To UBound(col) - 1

Dim head
As
New TableHeaderCell

Dim lkbtn
As
New LinkButtonlkbtn.Text = col(a, 0)

lkbtn.CommandArgument = col(a, 1)

lkbtn.CausesValidation =

False

AddHandler lkbtn.Click,
AddressOf tri_clickhead.Controls.Add(lkbtn)

Ligne.Cells.Add(head)

Next

'on ajoute la ligne en cours dans le tableauTable1.Rows.Add(Ligne)

'on ajoute une cellule vide pour la colonne qui accueillera les boutons pour le d‚tail des annonces

Dim head6
As
New TableHeaderCellLigne.Cells.Add(head6)

Table1.Rows.Add(Ligne)

'construction du corps du tableau

If Session(
"numero_page_liste") =
""
Then Session(
"numero_page_liste") =
"1"

Dim ligne_debut
As
Integer = (Session(
"numero_page_liste") - 1) * nbr_lignes_page.SelectedValue

Dim ligne_fin
As
Integer = ligne_debut + nbr_lignes_page.SelectedValue - 1

For l
As
Integer = ligne_debut
To ligne_fin

If l = table.Rows.Count
Then
Exit
For

Dim tRow
As
New TableRow()tRow.Height = 30

'Mise en forme des ligne en alternance

If l / 2 = Int(l / 2)
ThentRow.BackColor = Table1.BorderColor

tRow.ForeColor = Drawing.Color.FromName(

"#3f3f3f")

End
If

'colonne numero

Dim Col1
As
New TableCell()Col1.Text = Format(table.Rows(l).Item(

"numero"),
"0000000")Col1.Width = 80

tRow.Cells.Add(Col1)

'colonne Titre

Dim Col2
As
New TableCell()Col2.Text = table.Rows(l).Item(

"Titre").ToString &
"
" & table.Rows(l).Item(
"Sous-titre").ToStringtRow.Cells.Add(Col2)

'on ajoute un bouton pour chaque ligne

Dim btn
As
New Button()btn.Width = 85
btn.Text "D‚tails..."btn.Font.Name

"Courier New"btn.CommandArgument = Format(table.Rows(l).Item(

"numero"),
"0000000")

Dim Col6
As
New TableCellCol6.Controls.Add(btn)

AddHandler btn.Click,
AddressOf buttonClickCol6.Width = 90

tRow.Cells.Add(Col6)

'On ajoute la ligne a la tabletRow.HorizontalAlign = HorizontalAlign.Center

Table1.Rows.Add(tRow)

Next

End
Sub

Protected
Sub tri_click(
ByVal sender
As
Object,
ByVal e
As System.EventArgs)

Dim lkbtn
As LinkButton =
CType(sender, LinkButton)

connexion()table = recup_requete(Session(

"SQL"))deconnexion()

'on reconstruit la table avec la nouvelle requete
construction_table()

End
Sub
0
Rejoignez-nous