I have an ASP.net page that has a scriptmanager and an update panel on it. I need to call a javscript function from the codebehind on an server side event. i have tried using three methods to spit out javascript.
1) Clientscript.registerclientscriptblock()
2) Scriptmanager.registerClientscriptblock()
3) and also response.write()
None of the above seem to write to the page at all. what could be reason that all of the above methosd are failing?
what would be better method to call javascript now? my failed usage :
1) ClientScript.RegisterClientScriptBlock(Me.GetType(), "firstscript", "alert('test1')")
2) ScriptManager.RegisterClientScriptBlock(Me.Page, Me.GetType(), "testscript", "alert('test2')", True)
3) Response.Write("<script language='Javascript' type='text/javascript'>alert('test 3')</script>")
I also used Response.Write("-test-") to see if it actaully writes to the page. but it doesn't. Any insight would be much helpful.
You could try
RegisterStartupScript(here's a nice question about the differences between RegisterStartupScript and RegisterClientScriptBlock), but since yourResponse.Writedoesn't work, something appears to be very wrong.Are you sure you're testing your code correctly?