mvcTips:加载js文件和css文件的烦恼

 ASP.NET MVC中,由于Routing得原因,原来的引用js文件、css文件的方式经常会导致找不到文件错误,很多初学者对此非常苦恼。

 只好把文件放在mvc缺省能解析的Content和Scripts目录下,把一个js组件活活拆开。

 经过试验,可以采用如下的方法解析任意目录。

 

 1  <! DOCTYPE html PUBLIC  " -//W3C//DTD XHTML 1.0 Strict//EN "   " http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd " >
 2  < html xmlns = " http://www.w3.org/1999/xhtml " >
 3  < head runat = " server " >
 4       < title ><%= ViewData[ " Title " %></ title >
 5       < link href = " http://www.cnblogs.com/Content/Site.css "  rel = " stylesheet "  type = " text/css "   />
 6      
 7       < link rel = " stylesheet "  type = " text/css "  media = " screen "  href = " <%= Page.ResolveClientUrl( " ~/ Scripts / Uploadify / uploadify.css " )%> "   />
 8      
 9       < script type = " text/javascript "  src = " <%= Page.ResolveClientUrl( " ~/ Scripts / jquery - 1.3 . 2 .min.js " )%> " ></ script >     
10  </ head >

 

 

你可能感兴趣的:(tips)