There is more than one way to register the script. Maybe RegisterStartupScript may work better as it waits till the page is fully loaded in the browser before firing. Also I had my slash the wrong way around in the "text/javascript" attribute of the script tags.
HTML Page:
[HTML]<html>
<head>
<script type="text/javascript">
function myFunction(data)
{
alert(data);
}
</script>
</head>
<body>
</body>
</html>[/HTML]
ASP.NET page
string data = "Hello!";
string script = "<script type=\"text/javascript\">";
script += "myFunction('" + data + "');</script>";
Page.RegisterStartupScript("myscript", script);
Last edited by hollystyles; Aug 2nd, 2006 at 10:17 am.
Reputation Points: 262
Solved Threads: 68
Veteran Poster
Offline 1,181 posts
since Feb 2005