<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ClientAjax.aspx.cs" Inherits="AppliDeWS.ClientAjax" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title></title>

	<script src="http://ajax.aspnetcdn.com/ajax/4.5.2/1/MicrosoftAjax.js"></script>
	<script src="MonService.asmx/js"></script>



</head>
<body>
	<form id="form1" runat="server">
		<div>
		<%--	<asp:ScriptManager runat="server">
				<Services>
					<asp:ServiceReference Path="~/MonService.asmx" />
				</Services>
			</asp:ScriptManager>--%>


			n1 : <input type="text" id="n1" value="" /><br />
			n1 : <input type="text" id="n2" value="" /><br />
			<input type="button" value="+" onclick="additionner()" /><br />
			<div id="resultat"></div>
			<hr />

			recherche : <input type="text" id="recherche" value="" /><br />
			<input type="button" value="+" onclick="rechercher()" /><br />
			<pre id="personnes"></pre>


			<script type="text/javascript">
				function rechercher() {
					AppliDeWS.MonService.Rechercher($get("recherche").value,
						function (personnes) {
							///<param name="personnes" value="[{Nom: '', Prenom: '', Civilite: ''}]" />
							var sb = new Sys.StringBuilder();
							for (var i = 0; i < personnes.length; i++) {
								sb.appendLine(String.format( "{0} {1} {2}", personnes[i].Civilite, personnes[i].Prenom, personnes[i].Nom.toUpperCase() ))
							}
							$get('personnes').innerText = sb.toString();
						},
						function (wse) {
							$get("personnes").innerHTML = String.format("ERREUR {0} : {1}", wse.get_exceptionType(), wse.get_message());
						}
					);
				}

				function additionner() {
					AppliDeWS.MonService.Additionner($get("n1").value, $get("n2").value,
						function (resultat) {
							$get("resultat").innerHTML = String(resultat);
						},
						function (wse) {
							$get("resultat").innerHTML = String.format("ERREUR {0} : {1}", wse.get_exceptionType(), wse.get_message());
						}
					);
				}

			</script>



		</div>
	</form>
</body>
</html>
