See the solution below.
Default.aspx
<head runat="server">
<title></title>
<script type="text/javascript">
function SetValue(str) {
document.getElementById("foo").value = str; ;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<textarea id="foo"></textarea>
<asp:Button Text="Click" ID="btn" runat="server" onclick="btn_Click" />
</div>
</form>
</body>
</html>
Default.aspx.cs
protected void btn_Click(object sender, EventArgs e)
{
string str = "hello";
ScriptManager.RegisterStartupScript(Page, typeof(Page), "", "javascript:SetValue('"+str+"')", true);
}
I hope this will help you.