smk pobon
smk pobon

Reputation: 83

How can i Show the images in browser with mixit plugin where image link is coming from DB but the image is not showing in an Asp.net MVC application

My View:

@model IEnumerable<AdSite.Models.Album>
@{
    ViewBag.Title = "Index";
}


<button class="filter btn btn-primary" data-filter=".category-1">Category 1</button>
<button class="filter btn btn-success" data-filter=".category-2">Category 2</button>
<button class="sort btn btn-default" data-sort="my-order:asc">Ascending Order</button>
<button class="sort btn btn-primary" data-sort="my-order:desc">Descending Order</button>
<button class="filter btn btn-success" data-filter=".all">All</button>

<div id="Container">
    @foreach (var item in Model)
    {
    <div class=" mix category-1 all" data-my-order="@item.Id">
        <img alt="" src="@item.ProductTitle" />
    </div>
     }
</div>

@section scripts{
    <script src="~/Scripts/App/jquery.mixitup.min.js"></script>
    <script>
        $(function () {
            $('#Container').mixItUp();
        });
    </script>
 }

My Controller action:

 public ActionResult Index()
        {
            var db = new AlbumContext();
            return View(db.Albums.ToList());
        }

My model:

public class Album
    {
        public int Id { get; set; }`

        public string ProductTitle { get; set; }

        public string Description { get; set; }

    }

So, This are my codes. I need to show images by the mixit plugin used here on browser. I've used here a view referencing an Album model and a foreach loop is used for taking the imagelink given in the ProductTitle property. Also i uploaded an image in the Content folder of the project. When i'm running the code, the image link is showing in the browser's source code but the image is not showing. How can i fix it? Anyone's help is appreciated. Thank you.

Upvotes: 0

Views: 94

Answers (1)

smk pobon
smk pobon

Reputation: 83

I've solved this problem by using:

<img src="@Url.Content(@Model.ProductTitle)" />

in the view.I forgot to provide the @ sign before Model.ProductTitle. Now it's ok.

Thanks everyone.

Upvotes: 0

Related Questions