添加<脚本... />头... />&内LT标签;在ServerControl(ASP.NET)标签? [英] Add <Script ... /> tag within <Head ... /> tag in ServerControl (ASP.NET)?

查看:161
本文介绍了添加<脚本... />头... />&内LT标签;在ServerControl(ASP.NET)标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我会使用jQuery文件我的自定义ServerControl,所以我有头标记内以下行添加。

I'm gonna use JQuery files in my custom ServerControl , thus I have to add below line within Head tag.

<script type="text/javascript" src="jquery-1.4.3.min.js"></script>

我怎么能做到这一点的ServerControl用C#

How can I do it in ServerControl with C#

推荐答案

您可以使用注册自定义脚本的<一个href=\"http://msdn.microsoft.com/en-us/library/2552td66%28v=VS.90%29.aspx\">ClientScriptManager.RegisterClientScriptInclude页面加载时方法。或者,你可以在您的.aspx页面中的脚本。如果这是一个公共服务器控制,第一种方法可能更preferable。

You can register custom scripts using the ClientScriptManager.RegisterClientScriptInclude Method during the page load. Alternatively, you can just include the script in your .aspx page. If this is a public server control, the first method is probably more preferable.

编辑:另外,您可以在注册脚本中的&LT; HEAD&GT; 页面的标签如下:

alternatively you can register scripts in the <head> tag of the page as follows:

HtmlGenericControl jqueryInclude = new HtmlGenericControl("script");
jqueryInclude.Attributes.Add("type", "text/javascript");
jqueryInclude.Attributes.Add("src", "http://<path to jQuery>");
Page.Header.Controls.Add(jqueryInclude);

这篇关于添加&LT;脚本... /&GT;头... /&GT;&内LT标签;在ServerControl(ASP.NET)标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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