ASP.Net MVC: How to use razor variable in CSS file -


as per scenario need store path /img/product.png of image in razor variable , later want use razor variable in css file. below css code in css file

.test{     background: url('/img/product.png') no-repeat scroll 0 0 transparent; } 

so use code way below no luck still

.test{     background: url('@model.logourl') no-repeat scroll 0 0 transparent; } 

i see post http://www.codeproject.com/articles/171695/dynamic-css-using-razor-engine not want solve issue per post. let me know how sort issue. thanks

by default, mvc not support writing server side codes in external css file , external javascript files.

for case work, can add internal stylesheet in view file itself, work.

eg:

@{     viewbag.title = "title"; } <style>     .test {         background: url('@model.logourl') no-repeat scroll 0 0 transparent;     }   </style> 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -