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
Post a Comment