Le but de cet article est de construire une page AJAX contenant une gridView et une detailView du genre master/detail.
Les pré-requis sont :
L'installation de asp.net ajax fournit un ensemble d'outils supplémentaires dans la toolbox :
L'installation permet également de disposer d'un template de projet et de page pour asp.net ajax.
Pour commencer :
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server"> <title>Untitled Page</title>
</head>
<body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <div> </div> </form>
</body>
</html>
CODE HTML COMPLET DE LA PAGE
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="comptes.aspx.cs" Inherits="comptes" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server"> <title>Consultation des comptes</title> <link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"> </asp:ScriptManager> <div id="header" style="width: 678px; height: 65px"> <br /> <asp:Menu ID="Menu1" runat="server" BackColor="#E0E0E0" DynamicHorizontalOffset="2" Font-Names="Arial" Font-Size="Large" ForeColor="#0000C0" Orientation="Horizontal" StaticSubMenuIndent="10px" Width="780px"> <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" /> <DynamicHoverStyle BackColor="#7C6F57" ForeColor="White" /> <DynamicMenuStyle BackColor="#F7F6F3" /> <StaticSelectedStyle BackColor="#5D7B9D" /> <DynamicSelectedStyle BackColor="#5D7B9D" /> <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" /> <Items> <asp:MenuItem NavigateUrl="~/Default.aspx" Text="Accueil" Value="Accueil"></asp:MenuItem> <asp:MenuItem NavigateUrl="~/comptes.aspx" Text="Comptes" Value="Comptes"></asp:MenuItem> <asp:MenuItem NavigateUrl="~/mouvements.aspx" Text="Mouvements" Value="Mouvements"></asp:MenuItem> <asp:MenuItem Text="Données personnelles" Value="Données personnelles" NavigateUrl="~/client.aspx"></asp:MenuItem> <asp:MenuItem Text="Etats" Value="Etats"></asp:MenuItem> </Items> <StaticHoverStyle BackColor="#7C6F57" ForeColor="White" /> </asp:Menu> </div> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:ObjectDataSource ID="comptesDS" runat="server" SelectMethod="getComptesForClient" TypeName="bankdemoBL.Operations"> <SelectParameters> <asp:SessionParameter Name="idclient" SessionField="idclient" Type="Int64" /> </SelectParameters> </asp:ObjectDataSource> <div style="text-align: center"> <table> <tr> <td style="width: 500px; height: 210px;"> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" DataKeyNames="id" DataSourceID="comptesDS" ForeColor="Black" GridLines="Vertical" SelectedIndex="0" Width="347px"> <FooterStyle BackColor="#CCCCCC" /> <Columns> <asp:CommandField ShowSelectButton="True" /> <asp:BoundField DataField="id" Visible="False" /> <asp:BoundField DataField="numcompte" /> <asp:BoundField DataField="libcompte" /> </Columns> <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" /> <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" /> <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" /> <AlternatingRowStyle BackColor="#CCCCCC" /> </asp:GridView> </td> <td style="width: 850px; height: 210px;"> <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" CellPadding="4" DataSourceID="compteDS" ForeColor="#333333" GridLines="None" Height="50px" Width="265px"> <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" /> <EditRowStyle BackColor="#999999" /> <RowStyle BackColor="#F7F6F3" ForeColor="#333333" /> <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /> <Fields> <asp:BoundField DataField="id" HeaderText="id" SortExpression="id" /> <asp:BoundField DataField="numcompte" HeaderText="N° compte" SortExpression="numcompte" /> <asp:BoundField DataField="libcompte" HeaderText="Libellé" SortExpression="libcompte" /> <asp:BoundField DataField="datecreat" DataFormatString="{0:dd/MM/yyyy}" HeaderText="Date création" HtmlEncode="False" SortExpression="datecreat" /> </Fields> <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" /> <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <AlternatingRowStyle BackColor="White" ForeColor="#284775" /> </asp:DetailsView> <asp:ObjectDataSource ID="compteDS" runat="server" SelectMethod="getFicheCompte" TypeName="bankdemoBL.Operations"> <SelectParameters> <asp:ControlParameter ControlID="GridView1" Name="idcompte" PropertyName="SelectedValue" Type="Int64" /> </SelectParameters> </asp:ObjectDataSource> </td> </tr> </table> </div> </ContentTemplate> </asp:UpdatePanel> </form> </body>
</html>
| Octobre 2008 | ||||||||||
| L | M | M | J | V | S | D | ||||
| 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 | ||||||
|
||||||||||