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

<script runat="server">
  protected void AnalyzeName_Click(object sender, System.EventArgs e)
  {
    NameComponent.NameFunctionsClass Name = 
       new NameComponent.NameFunctionsClass();

    if (FirstName.Text.Length > 0) 
    {
      string firstName = FirstName.Text.ToString();
      Name.set_FirstName(ref firstName);
    }
  
    if (LastName.Text.Length > 0)
    {
      string lastName = LastName.Text.ToString();
      Name.set_LastName(ref lastName);
    }

    if (FullName.Text.Length > 0)
    {
      string fullName = FullName.Text.ToString();
      Name.set_FullName(ref fullName);
    }

    FirstName.Text = Name.get_FirstName();
    LastName.Text = Name.get_LastName();
    FullName.Text = Name.get_FullName();
    FullNameLength.Text = Name.FullNameLength.ToString();
  }
</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">Imię:</asp:Label>
        &nbsp;
        <asp:TextBox ID="FirstName" runat="server"></asp:TextBox>
      </P>
      <P>
        <asp:Label ID="Label2" runat="server">Nazwisko:</asp:Label>
        &nbsp;
        <asp:TextBox ID="LastName" runat="server"></asp:TextBox>
      </P>
      <P>
        <asp:Label ID="Label3" runat="server">Imię i nazwisko:</asp:Label>
        &nbsp;
        <asp:TextBox ID="FullName" runat="server"></asp:TextBox>
      </P>
      <P>
        <asp:Label ID="Label4" runat="server">Długość imienia i nazwiska:</asp:Label>
        &nbsp;
        <asp:Label ID="FullNameLength" runat="server" 
         Font-Bold="True">0</asp:Label>
      </P>
      <P>
        <asp:Button ID="AnalyzeName" runat="server" 
         OnClick="AnalyzeName_Click" Text="Analizuj"></asp:Button>
      </P>
    </form>
  </body>
</html>
