<%@ Page Language="VB" %>

<script runat="server">
    Protected Sub Button1_Click(ByVal sender As Object, 
       ByVal e As System.EventArgs)

       PopulateFields(TextBox1.Text)

    End Sub

    Private Sub PopulateFields(ByVal InputName As String)
       If InputName Is Nothing Then
          Label1.Text = "Cześć. Jak się nazywasz?"
       Else
          Label1.Text = "Witaj, " & InputName
       End If
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Strona AJAX-owa</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:Label ID="Label1" runat="server" 
                 Text="Cześć. Jak się nazywasz?"></asp:Label><br />
                <br />
                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
                <asp:Button ID="Button1" runat="server" Text="Podaj nazwisko" 
                 OnClick="Button1_Click" />
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    </form>
</body>
</html>
