ClientAjax.aspx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ClientAjax.aspx.cs" Inherits="AppliDeWS.ClientAjax" %>
  2. <!DOCTYPE html>
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head runat="server">
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <title></title>
  7. <script src="http://ajax.aspnetcdn.com/ajax/4.5.2/1/MicrosoftAjax.js"></script>
  8. <script src="MonService.asmx/js"></script>
  9. </head>
  10. <body>
  11. <form id="form1" runat="server">
  12. <div>
  13. <%-- <asp:ScriptManager runat="server">
  14. <Services>
  15. <asp:ServiceReference Path="~/MonService.asmx" />
  16. </Services>
  17. </asp:ScriptManager>--%>
  18. n1 : <input type="text" id="n1" value="" /><br />
  19. n1 : <input type="text" id="n2" value="" /><br />
  20. <input type="button" value="+" onclick="additionner()" /><br />
  21. <div id="resultat"></div>
  22. <hr />
  23. recherche : <input type="text" id="recherche" value="" /><br />
  24. <input type="button" value="+" onclick="rechercher()" /><br />
  25. <pre id="personnes"></pre>
  26. <script type="text/javascript">
  27. function rechercher() {
  28. AppliDeWS.MonService.Rechercher($get("recherche").value,
  29. function (personnes) {
  30. ///<param name="personnes" value="[{Nom: '', Prenom: '', Civilite: ''}]" />
  31. var sb = new Sys.StringBuilder();
  32. for (var i = 0; i < personnes.length; i++) {
  33. sb.appendLine(String.format( "{0} {1} {2}", personnes[i].Civilite, personnes[i].Prenom, personnes[i].Nom.toUpperCase() ))
  34. }
  35. $get('personnes').innerText = sb.toString();
  36. },
  37. function (wse) {
  38. $get("personnes").innerHTML = String.format("ERREUR {0} : {1}", wse.get_exceptionType(), wse.get_message());
  39. }
  40. );
  41. }
  42. function additionner() {
  43. AppliDeWS.MonService.Additionner($get("n1").value, $get("n2").value,
  44. function (resultat) {
  45. $get("resultat").innerHTML = String(resultat);
  46. },
  47. function (wse) {
  48. $get("resultat").innerHTML = String.format("ERREUR {0} : {1}", wse.get_exceptionType(), wse.get_message());
  49. }
  50. );
  51. }
  52. </script>
  53. </div>
  54. </form>
  55. </body>
  56. </html>