在Web用户控制的外部JS文件? [英] External JS file in web user control?

查看:189
本文介绍了在Web用户控制的外部JS文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们使用head标签中添加引用到我们的外部.js文件。我们也可以包括在体内脚本标记。但是我们如何包括我们在Web用户控件外部.js文件HTML页面?

In a html page we use the head tag to add reference to our external .js files .. we can also include script tags in the body .. But how do we include our external .js file in a web user control?

小谷歌搜索后,我得到了这一点。它的工作原理,但是这是唯一的方法是什么?

After little googling I got this. It works but is this the only way?

ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "MyUniquekey", @"<script src=""myJsFile.js"" type=""text/javascript""></script>", false);

- Zuhaib

-- Zuhaib

推荐答案

您也可以使用

Page.ClientScript.RegisterClientScriptInclude("key", "path/to/script.js");

这就是我总是这样做也无妨的方式

That's the way I always do it anyway

这篇关于在Web用户控制的外部JS文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆