I have my Controller which pass Data from to view as below:
IEnumerable<MovieDetails> jsonData = default(IEnumerable<MovieDetails>);
#region Constructor Request to get all Data
public MoviesController()
{
jsonData = GetJsonValues(URL);
}
public ActionResult Index()
{
return View(jsonData);
}
Now my view is rendering the controls as :
@model IEnumerable<VikiMVC.Models.MovieDetails>
@foreach (var movieDetails in Model)
{
<!--Deleted Divs for Simplicity -->
<img src = @movieDetails.Thumbnail alt = @movieDetails.Thumbnail
class="imgStyle"onclick="playMovie(this)" alt=@movieDetails.MovieURI/>
}
Now on click of Image I want to open up another view and access the @movieDetails related to that particular item.
My Movie Details class goes like :
public class MovieDetails
{
public string Title { get; set; }
public string Thumbnail { get; set; }
// public string URI { get; set; }
public string Description { get; set; }
public string MovieURI { get; set; }
// public List<Response> Response { get; set; }
}
SO when I click on an Image I should be able access the MovieURI specific to that particular image. We can do that using querystring , but Razor must be having some thing better.
Why do you have alt on image twice? Try this:
In js:
But I would suggest something like this (add Id field in model):
Action: