Check this sample
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript">
        function ShowMessage(message) {
            alert(message);
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <asp:Button ID="Button1" runat="server" Text="Button" OnClick = "Button_Click" />
    </form>
</body>
</html>
C#
 
protected void Button_Click(object sender, EventArgs e)
{
    ClientScript.RegisterStartupScript(this.GetType(), "myfunction", "ShowMessage('" + TextBox1.Text + "')", true);
}