从母版页注册javascript文件 [英] registering a javascript file from a master page
本文介绍了从母版页注册javascript文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有任何原因为什么无法从ASP.NET母版页的首页标记注册javascript文件?例如,我有以下(加上许多其他)文件引用:
Is there any reason why registering a javascript file from the head tags of an ASP.NET master page wouldn't work? For example, I have the following (plus many other) file referece:
<script type="text/javascript" src="/js/jquery/jquery-1.4.2.min.js"></script>
但是页面加载时jquery(以及所有其他JS参考)不起作用.
but jquery (and every other JS reference) doesn't work when the page loads.
有什么想法吗?谢谢.
Any thoughts? Thanks.
推荐答案
如果这不起作用,您可以尝试以下方法:
If that doesn't work, you can try this:
<script type="text/javascript" src="<%# ResolveUrl("~/js/jquery/jquery-1.4.2.min.js") %>"></script>
并在母版页的页面加载处理程序中添加以下代码:
and in your Page Load handler in the master page add this code:
Page.Header.DataBind();
这篇关于从母版页注册javascript文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文