Hello, I am new at this forum. I am trying to figure out how, if possible at all, to transfer data from an asp .net page into a javascript script in an HTML page.

string script = "<script type=\"text\\javascript\">function(){alert('some data');};</script>";
Page.RegisterClientScriptBlock("myscript", script);

That's an easy way. There are many others like AJAX google for that.

Thanks hollystyles, I tried the code and did not work. It seems that this code works when the script and the data are in the same page. I have the script in an html page different to the asp page.

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:

<script type="text/javascript">
    function myFunction(data)

ASP.NET page

string data = "Hello!";

string script = "<script type=\"text/javascript\">";
script += "myFunction('" + data + "');</script>";
Page.RegisterStartupScript("myscript", script);