is it possible to select the images without using the <img> tag for a source code like this :
@{
var db = Database.Open("infoabc");
var imgs = db.Query("SELECT * FROM homemedia").ToList();
var featured = imgs[new Random().Next(imgs.Count)];
}
<img src="@Href("homemedia/" + featured.ImageName)" />
For instance, using a <div class="media"></div> to do it? I'm not sure if the CSS can be dynamic using razor?!
dow7
Member
722 Points
449 Posts
select the images without using the <img> tag
Apr 12, 2012 04:45 PM|LINK
Hi,
is it possible to select the images without using the <img> tag for a source code like this :
@{ var db = Database.Open("infoabc"); var imgs = db.Query("SELECT * FROM homemedia").ToList(); var featured = imgs[new Random().Next(imgs.Count)]; } <img src="@Href("homemedia/" + featured.ImageName)" />For instance, using a <div class="media"></div> to do it? I'm not sure if the CSS can be dynamic using razor?!
Ken Tucker
All-Star
16797 Points
2608 Posts
MVP
Re: select the images without using the <img> tag
Apr 12, 2012 04:50 PM|LINK
If you give the img an id or css class you can select the img with JQuery
Space Coast .Net User Group
dow7
Member
722 Points
449 Posts
Re: select the images without using the <img> tag
Apr 12, 2012 05:08 PM|LINK
Ok, but i mean without using <img>
Thanks.
ps. solved it by changing the style of html elements.