ScriptManager和标签 [英] ScriptManager and the tag

查看:83
本文介绍了ScriptManager和标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我觉得这很有趣...

据我所记得,我们曾经将脚本引用放在

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.

推荐答案

免费点!您想让我们回答一个问题,还是最好将其发布为在休息室的观察报告或个人博客文章?
Free points! Is there a question you want us to answer or would you be better posting this as an observation in the lounge or a personal blog post?


这篇关于ScriptManager和标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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