如何包括来自MVC部分控制的CSS文件? [英] How can I include css files from an MVC partial control?

查看:142
本文介绍了如何包括来自MVC部分控制的CSS文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ASP.NET MVC和我有一个部分控制,需要一个特定的CSS& JS文件包括。是否有一种方法让父页面在页面的head部分呈现脚本链接标记,而不是只是渲染它们在内部的部分轮廓?

I'm using ASP.NET MVC and I have a partial control that needs a particular CSS & JS file included. Is there a way to make the parent page render the script and link tags in the 'head' section of the page, rather than just rendering them inline in the partial contol?

为了澄清我想包括的文件的控制是从一个视图渲染 Html.RenderPartial ,因此不能在其上具有服务器端内容控件。我想能够将文件包含在html 部分,以避免验证问题。

To clarify the control that I want to include the files from is being rendered from a View with Html.RenderPartial and so cannot have server-side content controls on it. I want to be able to include the files in the html head section so as to avoid validation issues.

推荐答案

http://www.codeproject.com/Articles/38542/Include-Stylesheets-and-Scripts-From-A-WebControl-.aspx

本文包含有关覆盖HttpContext.Response.Filter的信息,这对我非常有用。

This article contains information about overriding HttpContext.Response.Filter which worked great for me.

这篇关于如何包括来自MVC部分控制的CSS文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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