<%@ Page Language="C#" %>

<!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 id="Head1" runat="server">
  <title>ASP.NET AJAX</title>

  <script language="Javascript" type="text/javascript">
  debugger;
  function callService(f) {
    document.getElementById("c").innerHTML = "";
    Sys.Debug.trace("Calling MathService");
    Sys.Debug.traceDump(MathService, "MathService: ");
    MathService.ExtendedDivideNumbers(
      parseInt(f.elements["a"].value),
      parseInt(f.elements["b"].value),
      callComplete,
      callError);
  }

  function callComplete(result) {
    Sys.Debug.trace("Received result!");
    Sys.Debug.traceDump(result, "result: ");
    document.getElementById("c").innerHTML = 
      result.result + 
      " (calculated at " + 
      result.calculationTime + 
      ")";
  }

  function callError(result) {
    Sys.Debug.fail(
      result.get_exceptionType() +
      ": " +
      result.get_message() +
      "\n" +
      result.get_stackTrace());
  }
  </script>

</head>
<body>
  <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server"
      ScriptMode="Debug">
      <Services>
        <asp:ServiceReference Path="MathService.asmx" />
      </Services>
    </asp:ScriptManager>
    <div>
      <nobr>
        <input type="text" id="a" name="a" size="2" />
        :
        <input type="text" id="b" name="b" size="2" />
        =
        <span id="c" style="width: 50px;"></span>
      </nobr>
      <br />
      <input type="button" value="Podziel liczby" onclick="callService(this.form);" />
      <br />
      <textarea id="TraceConsole" rows="10" cols="50">Informacje z procesu debugowania:
</textarea>
    </div>
  </form>
</body>
</html>
