Link to home
Start Free TrialLog in
Avatar of dan henderson
dan hendersonFlag for United States of America

asked on

how to pass image source from model property.

I have a razor view index that gets  @model IEnumerable<Test.Models.Pet> collection from the controller.  The model has 2 properties, ImageUrl and Name.
I build the view this way:
@for (int cnt=0;cnt<Model.Count();cnt++)
    {
        //string imageUrl = @Model.ElementAt(cnt).ImageUrl;
        if (cnt == 0)
        {
            <div class="col span-1-of-4 box">
                <h4>@Html.DisplayFor(model => model.ElementAt(cnt).Name)</h4>
                <img src="WHAT GOES HERE" alt="@Html.DisplayFor(model => model.ElementAt(cnt).ImageUrl)" width="100" height="100" />
            </div>
        }
}

I can get the imageurl value in the alt attribute(just to see what I've returned), but can't figure out what to put in the src="" attribute.  Please help.
ASKER CERTIFIED SOLUTION
Avatar of Misha
Misha
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dan henderson

ASKER

I thought I had tried this, but maybe not.  Thanks for the help!!
Glad to help you!