On my MVC3 _Layout.cshtml page I show a banner image like this
<body>
<div id="page">
<div id="nonFooter">
<div id="header">
<img id="headerBanner" src="@Url.Content("~/Content/Images/banner.jpg")" alt="Banner" />
</div> ....
Simple enough.
What I want to do is display a different image for each client using the site, most likely this will be determined by the url, eg: www.mysite.com/clientA/Home (clientA determines which image to be used)
Essentially the desired functionality is a bit CMS like but we don't need a full blown CMS, we just need to replace a few images and colors.
So the question is what is the best way to do this?
My thinking so far is to use jQuery to update the src like this
<script type="text/javascript">
$(document).ready(function () {
$('#headerBanner').attr('src', whatToPutHere? );
});
But I'm stuck on 'best practice' for the whatToPutHere.
Should it be...
- An image put in the ViewBag in the serverside code (eg. @ViewBag.BannerImage)?
- An image put in the ViewModel?
- Some kind of server call to get/load the image (logic to determine which image to use must be server side)...(would this be another round trip though?)?
- ...another approach?
Any help much appreciated :-)