troubleshooting Question

how to pass image source from model property.

Avatar of dan henderson
dan hendersonFlag for United States of America asked on
C#ASP.NET
3 Comments1 Solution111 ViewsLast Modified:
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.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros