如何在 </body> 之前添加脚本代码标记 ASP.NET [英] How to Add script codes before the </body> tag ASP.NET
问题描述
问题来了,
在 Masterpage 中,谷歌分析代码粘贴在 body
标签的末尾之前.
In Masterpage, the google analytics code were pasted before the end of body
tag.
在 ASPX 页面中,我需要使用代码隐藏 ClientScript
生成一个脚本(google addItem tracker)并将其放在 body
标记的末尾之前,因为该脚本使用谷歌分析变量.
In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript
and put it before the end of body
tag, because this script uses the google analytics variables.
我怎样才能做到这一点?
How can i achieve this?
推荐答案
如果你能够避免使用 ClientScript
,一个不优雅但简单的方法就是在页面中粘贴一个文字您希望在何处呈现脚本并将脚本从代码隐藏中放入其中(即 myLiteral.Text = "client script";
).
An inelegant but simple approach, if you're able to avoid using ClientScript
, would be to just stick a literal in the page where you want your script to be rendered and put the script in there from your codebehind (i.e. myLiteral.Text = "client script";
).
这篇关于如何在 </body> 之前添加脚本代码标记 ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!