Reputation: 11349
A trivial question but the solution escapes me at the moment
We have a CMS where the Layout and CSS ( names only, no extension ) are retrieved from db !
the .cshtml has this code which does NOT compile cleanly
....
<link href="~/Content/themes/@ViewBag.dbConfig.Theme/style/@ViewBag.dbConfig.CssName.css" rel="stylesheet">
where the variable is
ViewBag.dbConfig.CssName
without the .css extension
Is there a way to make this work without changing the config ?
Upvotes: 0
Views: 157
Reputation: 1056
use parantesese and trim:
<link href="~/Content/themes/@(ViewBag.dbConfig.Theme.trim())/style/@(ViewBag.dbConfig.CssName.trim()+".css")" rel="stylesheet">
Upvotes: 0
Reputation: 16928
First I would wrap your variable usages... See if that yields something more in line with what you expected.
<link href="~/Content/themes/@(ViewBag.dbConfig.Theme)/style/@(ViewBag.dbConfig.CssName).css" rel="stylesheet">
Upvotes: 1