如何添加脚本在页面< HEAD>< /头>动态 [英] How to add Script in the Page <head></head> dynamically

查看:304
本文介绍了如何添加脚本在页面< HEAD>< /头>动态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用asp.net 4和C#。

I use asp.net 4 and c#.

我有一个Web页面从内部Web用户控件。
当我包括Web用户控件,我想也包括编程为最终生成的页面标签内的一些脚本。

I have a Web User Control inside a Web From page. When I include the Web User Control I would like also include programmatically some script within the tags for the final generated page.

任何想法,该怎么办呢?
也许ScriptManager的可以帮助这个吗?

Any idea how to do it? Maybe ScriptManager could help on this?

请为我提供code的样品我pretty在开发感谢您的时间对这个!

Please provide me a sample of code I'm pretty new at developing thanks for your time on this!

推荐答案

彼得的回答将添加到页面中,而不是head元素。看看这篇文章:

Peter's answer will add to the page, but not the head element. Take a look at this article:

<一个href=\"http://weblogs.asp.net/johnkatsiotis/archive/2008/08/08/add-scripts-to-head-dynamically.aspx\">http://weblogs.asp.net/johnkatsiotis/archive/2008/08/08/add-scripts-to-head-dynamically.aspx

它提供了一个很好的清洁方式使用扩展方法的脚本添加到head元素。

It provides a nice clean way to add a script to the head element using an extension method.

这篇关于如何添加脚本在页面&LT; HEAD&GT;&LT; /头&GT;动态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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