从添加code的JavaScript基准背后(C#) [英] Add JavaScript reference from code behind (C#)
本文介绍了从添加code的JavaScript基准背后(C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以动态地从code添加aspx.cs背后javascript参考?
Is it possible to add javascript reference dynamically from code behind aspx.cs?
这样的:
private void AddScriptReference(string path)
{
//Add reference to <head></head>
}
应导致脚本引用被添加到页面的头,像这样的:
Should result in a script reference being added to the head of the page, like this:
<html>
<head>
<script type="text/javascript" src="path-to-script.js"></script>
</head>
</html>
这可能吗?
推荐答案
您可以使用<$c$c>ASP.NET阿贾克斯的ScriptManager 这样做。
You can use the ASP.NET Ajax ScriptManager
to do so.
将它添加到您的母版,并使用<一个href=\"http://msdn.microsoft.com/en-us/library/bb360649.aspx\"><$c$c>ScriptManager.RegisterClientScriptInclude$c$c>从codebehind。
Add it to your masterpage, and use ScriptManager.RegisterClientScriptInclude
from your codebehind.
这篇关于从添加code的JavaScript基准背后(C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文