RegisterClientScriptBlock - not firing

60 views Asked by At

I been looking at the RegisterClientScriptBlock object which runs some JavaScript code and I have been trying to use it.

I currently have

ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "<script type=\"text/javascript\">function clearStorage() {alert('here');localStorage.clear();}</script>", false);

I would expect the alert to pop up when the code is hit but it never does, is the parameters correct or am I going down the wrong road?

Thanks

Chris

1

There are 1 answers

0
Alex Mendez On BEST ANSWER

Try this:

ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "<script type=\"text/javascript\">function clearStorage() {alert('here');localStorage.clear();} clearStorage();</script>", false);