I'm currently trying to register a JS function call from a .NET page which simply calls a small function on the .aspx page that will close the window.
The RegisterClientScriptBlock code is like this:
Page.ClientScript.RegisterClientScriptBlock (typeof(Page), "closeBox", "<script type='text/javascript'>closeBox();</script>");
This sort of thing works elsewhere in the application on different pages. However, in this case I get a runtime JS error: Error: Expected '/' and when I debug, sure enough the inserted javascript is:
<script type='text/javascript'>closeBox();<
As you can see, it hasn't added the /script> for some reason! I've tried to leave out the tags myself and used:
Page.ClientScript.RegisterClientScriptBlock (typeof(Page), "closeBox", "closeBox();", true);
but with the same results.
I've also tried RegisterStartupScript to no avail.
Has anyone else come across this before? Any ideas on what's causing it and on how to fix it?