[C#] création de plusieurs ImageButton en code-behind
Bonjour,
Voilà mon problème :
J'ai un UpdatePanel créé dans ma page aspx :
Code:
1 2 3 4 5 6 7 8
| <asp:UpdatePanel ID="UPnDroite" runat="server" UpdateMode="Conditional"
onload="UPnDroite_Load">
<ContentTemplate>
<asp:Label ID="LbDroite" CssClass="lbgauche" runat="server" Text="Label">Scenarios</asp:Label>
<asp:Panel ID="DivListeGroupe" CssClass="divlistegroupe" runat="server"></asp:Panel>
<asp:Label ID="tGroupe" runat="server" Text="" CssClass="invisible"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel> |
par code-behind, j'insère plusieurs infos dans mon Panel DivListeGroupe.
résumé du code pour faire plus simple :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
int i = 0;
foreach (Equipment Lumiere in LstAutres.OrderBy(Name => Name.Name))
{
UpdatePanel UPScen = new UpdatePanel();
UPScen.ID = "UP" + i;
UPScen.ChildrenAsTriggers = true;
UPScen.UpdateMode = UpdatePanelUpdateMode.Conditional;
ImageButton iScen = new ImageButton();
iScen.ID = "iscenar" + i;
iScen.CssClass = "ivalscenario";
iScen.Click += new ImageClickEventHandler(iScen_Click);
UPScen.ContentTemplateContainer.Controls.Add(iScen);
DivListeGroupe.Controls.Add(UPScen);
i++;
} |
et enfin ma fonction ImageClickEnventHandler :
Code:
1 2 3 4
| protected void iScen_Click(object sender, ImageClickEventArgs e)
{
LbDroite.Text = "click";
} |
2 questions :
- lorsque je clique sur une des ImageButton, ma fonction iScen_Click n'est pas exécutée.
- j'aimerai après avoir cliqué que seul l'UpdatePanel contenant le bouton soit rafraichit. Actuellement l'ApdatePanel parent est complètement rafrichit.
Comment faut-il faire ?