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

<script runat="server">
  protected void Calculate_Click(object sender, System.EventArgs e)
  {

    DivideComponent.DivideClass myDivide = new DivideComponent.DivideClass();

    try
    {
      double numerator = double.Parse(Numerator.Text);
      double denominator = double.Parse(Denominator.Text);
      Answer.Text = myDivide.DivideNumber(ref numerator, 
         ref denominator).ToString();
    }
  
    catch (Exception ex)
    {
      Answer.Text = ex.Message.ToString();
    }
  
    System.Runtime.InteropServices.Marshal.ReleaseComObject(myDivide);
  
  }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head runat="server">
     <title>Wykorzystanie komponentów COM</title>
  </head>
  <body>
    <form id="form1" runat="server">
      <p>
        <asp:Label ID="Label1" runat="server">Licznik:</asp:Label>
        &nbsp;
        <asp:TextBox ID="Numerator" runat="server"></asp:TextBox>
      </p>
      <p>
        <asp:Label ID="Label2" runat="server">Mianownik:</asp:Label>
        &nbsp;
        <asp:TextBox ID="Denominator" runat="server"></asp:TextBox>
      </p>
      <p>
        <asp:Label ID="Label3" runat="server">
         Wynik podzielenia licznika przez mianownik:</asp:Label>
        &nbsp;
        <asp:Label ID="Answer" runat="server" Font-Bold="True">0</asp:Label>
      </p>
      <p>
        <asp:Button ID="Calculate" 
         runat="server"
         OnClick="Calculate_Click"
         Text="Oblicz">
        </asp:Button>
      </p>
    </form>
  </body>
</html>
