0

我的页面中有 java 脚本,我想从函数后面的 vb.net 代码中调用它,并且不想调用它(onload 或 onclick 或任何类似事件),但我想从执行 looping.so 的函数中调用它它会多运行一次

4

2 回答 2

3

你需要这样做:

 ' Define the name and type of the client scripts on the page. 
    Dim csname1 As [String] = "PopupScript"
    Dim cstype As Type = Me.[GetType]()

    ' Get a ClientScriptManager reference from the Page class. 
    Dim cs As ClientScriptManager = Page.ClientScript

    ' Check to see if the startup script is already registered. 
    If Not cs.IsStartupScriptRegistered(cstype, csname1) Then
        Dim cstext1 As New StringBuilder()
        cstext1.Append("<script type=text/javascript> getval('elementid') </") 'Your javascript function
        cstext1.Append("script>")

        cs.RegisterStartupScript(cstype, csname1, cstext1.ToString())
    End If

资源。

于 2012-05-08T11:24:41.443 回答
0

这实际上可以使用 SignalR。

https://github.com/SignalR/SignalR

很酷的东西。

持久连接听起来会满足您的需求。

https://github.com/SignalR/SignalR/wiki/PersistentConnection

于 2012-05-08T12:24:53.960 回答