Ouvrir une popup avec un buttonField dans un GridView
Le souci est trés simple : on clique sur un ButtonField dans un GridView et une popup s'ouvre grâce à du Javascript.
Pour l'instant j'ai essayé pas mal de chose, mais ne fonctionne. Le plus gros ennui que j'ai est qu'il n'y a pas de mesage d'erreur. Il ne se passe tout simplement rien ou alors c'est le UpdatePanel qui mange le message, mais là, je ne sais pas comment aller le chercher.
Donc, si une âme charitable passe par là et vois l'erreur, un grand merci d'avance.
Voici mon code HTML :
Code:
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
|
<asp:SqlDataSource ID="sdsGvCampagne" runat="server"
ConnectionString="<%$ ConnectionStrings:CS %>">
</asp:SqlDataSource>
<ajax:UpdatePanel ID="upCampagne" runat="server" UpdateMode="Always">
<Triggers>
<ajax:AsyncPostBackTrigger ControlID="gvCampagne" EventName="RowCommand" />
<ajax:AsyncPostBackTrigger ControlID="gvCampagne" EventName="PageIndexChanged" />
</Triggers>
<ContentTemplate>
<asp:GridView ID="gvCampagne" runat="server"
DataSourceID="sdsGvCampagne"
AutoGenerateColumns="false"
AllowPaging="true"
DataKeyNames="Id_Campagne"
PageSize="15"
PagerStyle-HorizontalAlign="Center">
<PagerSettings Position="Bottom"
Mode="NextPreviousFirstLast"
FirstPageText="Début"
LastPageText="Fin"
NextPageText="Suivant"
PreviousPageText="Précédent" />
<Columns>
<asp:BoundField DataField="Id_Campagne" HeaderText="ID" />
<asp:BoundField DataField="Libelle" HeaderText="Libelle" />
<asp:BoundField DataField="Regie" HeaderText="Régie" />
<asp:ButtonField ButtonType="Image" ImageUrl="~/App_Themes/jemprunte/loupe.png" Text="Apercu" CommandName="Apercu" />
<asp:ButtonField ButtonType="Image" ImageUrl="~/App_Themes/Jemprunte/modifier_16.png" Text="Modifier" CommandName="Modif" />
</Columns>
</asp:GridView>
<asp:PlaceHolder ID="FormuModif" runat="server"></asp:PlaceHolder>
</ContentTemplate>
</ajax:UpdatePanel> |
Et mon code Behind.
Code:
1 2 3 4 5 6 7 8
|
Protected Sub gvCampagne_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gvCampagne.RowCommand
Select Case e.CommandName
Case "Apercu"
Dim IdCell As TableCell = CType(gvCampagne.Rows(Convert.ToInt32(e.CommandArgument)), GridViewRow).Cells(0)
Me.Page.ClientScript.RegisterStartupScript(Me.GetType, "monscript", "<script type='text/javascript'>OuvrirPopupParam('/Default.aspx?page=18&mail=campagne&campagne=" & IdCell.Text & "', 1050, 750, 'no', 'no', 'no', 'no', 'no', 'yes', 'no');</script>")
End Select
End Sub |