Tuesday, June 21, 2011

calling javascript function from c#code

<script>
function hi(var someVar)
{
   document.write("hi " + someVar);
}
</script>

in .NET on a method you wish to call the javascript method from:
string whatever = "blahblah";
Page.RegisterStartupScript("myScript", "<script language=JavaScript>hi('" + whatever + "');</script>");

I hope that is what you are looking for and hope it helps!

No comments:

Post a Comment