// GET: Tracks/Albums/5 // Attention - 07 - This get-albums-for-artist method is called from JavaScript+Ajax public ActionResult Albums(int? id) { // Fetch the collection var c = m.AlbumGetAllForArtist(id.GetValueOrDefault()); // If null, create an empty collection if (c == null) { c = new List<AlbumBase>(); } // Create a form var form = new AlbumForm(); form.AlbumList = new SelectList(c, dataValueField: "AlbumId", dataTextField: "Title"); return PartialView("_AlbumList", form); // Attention - 08 - Notice several things in the list-of-albums view... // The dropdown list has an "onchange" attribute that calls a JavaScript method // Attention - 09 - Study the albumSelected() method in the JavaScript core.js source code file }
// GET: Tracks/Albums/5 // Attention - 07 - This get-albums-for-artist method is called from JavaScript+Ajax public ActionResult Albums(int?id) { // Fetch the collection var c = m.AlbumGetAllForArtist(id.GetValueOrDefault()); // If null, create an empty collection if (c == null) { c = new List <AlbumBase>(); } // Create a form var form = new AlbumForm(); form.AlbumList = new SelectList(c, dataValueField: "AlbumId", dataTextField: "Title"); return(PartialView("_AlbumList", form)); // Attention - 08 - Notice several things in the list-of-albums view... // The dropdown list has an "onchange" attribute that calls a JavaScript method // Attention - 09 - Study the albumSelected() method in the JavaScript core.js source code file }