在 html 页面中,我们使用 head 标签来添加对外部 .js 文件的引用。我们还可以在主体中包含 script 标签。但是我们如何将外部 .js 文件包含在网络用户控件中?
经过一点谷歌搜索,我得到了这个。它有效,但这是唯一的方法吗?
ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "MyUniquekey", @"<script src=""myJsFile.js"" type=""text/javascript""></script>", false);
-- 祖海布
最佳答案
你也可以使用
Page.ClientScript.RegisterClientScriptInclude("key", "path/to/script.js");
我一直都是这样做的
关于asp.net - Web 用户控件中的外部 JS 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/280201/