我的问题很简单,如何从我的httphandler调用我的JavaScript函数runExec()
?这不起作用
ScriptManager.RegisterStartupScript(Me, Me.GetType(), "myFunction", "runExec();", True)
它给我以下错误
Error 5 Overload resolution failed because no accessible 'RegisterStartupScript' can be called with these arguments:
'Public Shared Sub RegisterStartupScript(control As System.Web.UI.Control, type As System.Type, key As String, script As String, addScriptTags As Boolean)': Value of type 'Sample' cannot be converted to 'System.Web.UI.Control'.
'Public Shared Sub RegisterStartupScript(page As System.Web.UI.Page, type As System.Type, key As String, script As String, addScriptTags As Boolean)': Value of type 'Sample' cannot be converted to 'System.Web.UI.Page'. C:\Users\Fares\Desktop\RemotePayment 13.10.2014\Sample.ashx 144 17 C:\...\RemotePayment 13.10.2014\
答案 0 :(得分:0)
根据MSDN,HTTP Handlers是“端点”。所以你不能提示客户端运行JavaScript代码。 HTTP Handlers正在响应请求,唯一的想法是我可以说你可以将javascript代码写入响应,然后在客户端浏览器中运行它。这样的事情:
Public Sub ProcessRequest(context As HttpContext)
...
context.Response.Write("<script>muFunc();</script>")
...
End Sub
仅当您的请求是 text / html 请求时才有效。