This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="row"> | |
@foreach (var item in Model) | |
{ | |
<div class="col-md-4"> | |
<a href="#" data-toggle="modal" data-target="#youtube-modal" data-video-title="@item.Title" data-video-id="@item.Id" data-video-width="@item.Width" data-video-height="@item.Height"> | |
<img src="http://img.youtube.com/vi/@item.Id/mqdefault.jpg" alt="@item.Id" /> | |
</a> | |
</div> | |
} | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var player; | |
$('#youtube-modal').on('show.bs.modal', function (event) { | |
var link = $(event.relatedTarget); | |
var videoId = link.data('video-id'); | |
var videoTitle = link.data('video-title'); | |
var videoWidth = link.data('video-width'); | |
var videoHeight = link.data('video-height'); | |
var modal = $(this); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="modal fade" id="youtube-modal"> | |
<div class="modal-dialog modal-lg"> | |
<div class="modal-content"> | |
<div class="modal-header"> | |
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> | |
<h4 class="modal-title"></h4> | |
</div> | |
<div class="modal-body"> | |
<!-- Player for Youtube API --> | |
<div id="player"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@model DropDownListExample.ViewModels.GenericViewModel | |
@Html.DropDownListFor(m => m.SelectedCountryId, Model.CountryItems) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ActionResult Index() | |
{ | |
var genericViewModel = new GenericViewModel(); | |
return View(genericViewModel); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GenericViewModel | |
{ | |
[Display(Name = "Country")] | |
public Guid SelectedCountryId { get; set; } | |
public List<SelectListItem> CountryItems { get; set; } | |
public GenericViewModel() | |
{ | |
var ddlHelper = new DropDownListHelper(); | |
this.CountryItems = ddlHelper.CountryItems.ToList(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public IEnumerable<SelectListItem> DefaultItem | |
{ | |
get | |
{ | |
return Enumerable.Repeat(new SelectListItem | |
{ | |
Value = "", | |
Text = "- SELECT -" | |
}, count: 1); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private List<Country> _countries; | |
public IEnumerable<SelectListItem> CountryItems | |
{ | |
get | |
{ | |
IEnumerable<SelectListItem> selectCountries = new List<SelectListItem>(); | |
selectCountries = _countries.Select(x => new SelectListItem | |
{ | |
Value = x.Id.ToString(), | |
Text = x.Name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Country | |
{ | |
public Guid Id { get; set; } | |
public string Name { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Video | |
{ | |
public string Id { get; set; } | |
public string Title { get; set; } | |
public string Width { get; set; } | |
public string Height { get; set; } | |
} |