我的页面中有java脚本,我想从函数的后面的vb.net代码中调用它并且不想调用它(onload或onclick或任何类似的事件)但是我想从函数中调用它looping.so它将运行一次
答案 0 :(得分: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
答案 1 :(得分:0)
这实际上可以使用SignalR。
https://github.com/SignalR/SignalR
很酷的东西。
持久连接听起来就像你正在寻找的那样。
https://github.com/SignalR/SignalR/wiki/PersistentConnection