[英]ASP.NET Calling defined JS-function with RegisterStartupScript
In ASP.NET we are calling defined js-functions with the: 在ASP.NET中,我们使用以下命令调用已定义的js函数:
Page.ClientScript.RegisterStartupScript(GetType(), "", "JSFuncNameHere();", true);
I wonder: 我想知道:
key
? key
? As I have tested, I can left it empty and the existed JS-function shall be called. Probably because this is more generic solution, since by just adding 2 characters you get the same result and if you need you can add arguments and anything else. 可能是因为这是更通用的解决方案,因为只需添加2个字符,您将获得相同的结果,并且如果需要,可以添加参数和其他任何内容。
For both of these the same reason - the method will detect if you run the same script multiple times and in such case, call it just once. 由于这两个相同的原因-该方法将检测您是否多次运行同一脚本,在这种情况下,只需调用一次即可。 The two arguments are the means how it identifies duplicates - a key is not sufficient since another class in a different library might be using the same key - so you need to pass in the type of your own class to ensure that the script is executed when you want it to.
这两个参数是用来标识重复项的方法-一个键是不够的,因为不同库中的另一个类可能使用相同的键-因此,您需要传入自己的类的类型以确保脚本在执行时执行你想要它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.