You can call JavaScript from C# code. Here is the sample:
<script>
function hi(var someVar)
{
document.write("hello " + someVar);
}
</script>
C# code behind looks like:
string passName = "username";
Page.RegisterStartupScript("myScript", "<script language="JavaScript">hi('" + passName + "');</script>");