问题描述
我觉得这很有趣...
据我所记得,我们曾经将脚本引用放在
I think this is interesting...
As far as I can remember we used to put our script references in the
<head>
标签.但是必须将ScriptManager放在
tags. But a ScriptManager has to be placed inside the
<form>
标签.
这意味着,如果您在母版页上通过ScriptManager包含类似jQuery的库,则在ScriptManager位置上方的ContentPlaceHolders中使用jQuery的任何脚本都会失败.
奇怪,不是吗?您可能会认为ScriptManager将是Microsoft允许将其放置在表单外部或仅将其内容呈现在head标签中的一个控件.
同时,我将把jQuery引用从ScriptManager中删除,并将其粘贴在头部.我们的头部有一个ContentPlaceHolder,许多页面正在使用它作为脚本.
tags.
This means if you are including a library like jQuery via your ScriptManager on your masterpage that any script using jQuery in ContentPlaceHolders above the ScriptManager placement will fail.
Odd, isn''t it? You''d think that ScriptManager would be the one control that Microsoft would allow to be placed outside the form or simply render it''s contents in head tags.
Meanwhile, I''m going to take my jQuery references out of the ScriptManager and stick them in the head. We have a ContentPlaceHolder in the head and a number of pages are using that for their script.
推荐答案
这篇关于ScriptManager和标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!