我正在尝试从我的VB.NET代码中调用JavaScript代码并使用以下代码:
Protected Sub ApplyGridViewPageChangingActions(ByVal sender As Object, ByVal e As EventArgs) Handles GridView_Body.PageIndexChanged
Dim oldPageIndex As Integer = Context.Session("GridViewPage")
If GridView_Body.PageIndex > oldPageIndex Then
Dim func As String = "ApplyGridViewPageChangingActions('" + Context.Session("LastFundCode") + "', '" + Context.Session("ExpOrColl") + "');"
Context.Session("GridViewPage") = GridView_Body.PageIndex
ScriptManager.RegisterStartupScript(Me, Me.GetType(), "ApplyGridViewPageChangingActions", func, False)
End If
End Sub
但是我收到此错误消息:
JavaScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: The script tag registered for type 'ASP.lsc_code_placeorders_aspx' and key 'ApplyGridViewPageChangingActions' has invalid characters outside of the script tags: ApplyGridViewPageChangingActions('baef', '0');. Only properly formatted script tags can be registered.
为什么格式不正确? ApplyGridViewPageChangingActions('baef','0');看起来完全可以接受。