简体   繁体   English

如何在vb.net Sub结束时调用javascript函数?

[英]How can I call a javascript function at the end of a vb.net Sub?

如何在vb.net S结束时调用javascript函数

If your VB.NET subroutine is running on the server, and you want the JavaScript to run on the client, you can't. 如果您的VB.NET子例程正在服务器上运行,并且您希望JavaScript在客户端上运行,则不能。

The only way you can come close is by having your VB.NET subroutine construct some appropriate JavaScript in the page being served such that the JavaScript will run when it's loaded. 您可以接近的唯一方法是让您的VB.NET子例程在所服务的页面中构造一些适当的JavaScript,以使JavaScript在加载时运行。

查看ClientScriptManager类的RegisterClientScriptBlock方法。

If you are trying to do what I think you are, you can use Page.RegisterStartupScript 如果您尝试按我认为的那样做,可以使用Page.RegisterStartupScript

Dim Script As String = “<script language=javascript” id=’myClientScript’>myFunction();</script>”
Page.RegisterStartupScript(“callTest”,Script)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM