我可以在每个内容页使用ASP.NET WebForms母版页包括不同的javascript / css文件? [英] Can I Include different javascript/css files per Content Page using ASP.NET WebForms Master Pages?

查看:181
本文介绍了我可以在每个内容页使用ASP.NET WebForms母版页包括不同的javascript / css文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个内容页使用相同的主页,并不都需要包含在< head> 标签中的相同的javascript和css文件。

I have several Content Pages using the same Master Page, that don't all need the same javascript and css files included in the <head> tag.

是否可以更改内容页面中< head> 标签的内容?

Is it possible to change the contents of the <head> tag from the Content Pages?

推荐答案

这是,但我建议做一点不同。我在关闭body标签的上方放置一个内容地址。然后我填充每个内容页面所需的JS脚本。

it is, but I recommend doing it a bit different. I place a content place holder right above the close body tag. Then I populate the required JS scripts per content page. This will allow you to place the scripts at the bottom, but you could also do the same with the placeholder in the header.

你也可以通过编程来实现:

You can also do so programmatically:

HtmlGenericControl js = new HtmlGenericControl("script");
js.Attributes["type"] = "text/javascript";
js.Attributes["src"] = "jscript/jquery.js";
Page.Header.Controls.Add(js);

这篇关于我可以在每个内容页使用ASP.NET WebForms母版页包括不同的javascript / css文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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