|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.UI;
using Mvc.Models;
using System.Web.Routing;
namespace Mvc.Views.Music
{
public partial class Artists : ViewPage< List<Artist> > //ViewPage
{
protected override void OnLoad(EventArgs e)
{
// Create the menu
AddMenu();
ArtistList.DataSource = ViewData;
// With the loosely coupled object collection, ViewData needs
// to cast
//ArtistList.DataSource = (List<Artist>)ViewData["Artists"];
ArtistList.DataBind();
}
/// <summary>
/// Create a simple alphabetic menu for navigation
/// </summary>
private void AddMenu()
{
// Build alphabetic menu
for(char c = 'A'; c <= 'Z'; c++)
{
string link3 = Html.RouteLink(c.ToString(), new RouteValueDictionary(new { letter = c.ToString() }));
//string link2 = Html.RouteLink(c.ToString(), "ArtistRoute", c);
//string link2 = Html.RouteLink(c.ToString(), "ArtistRoute", new RouteValueDictionary(new { controller = "Music", letter = c.ToString() }));
string link = Html.ActionLink(c.ToString(), "Artists", new RouteValueDictionary( new { controller = "Music", letter = c.ToString() }) );
Alphabet.Controls.Add(new LiteralControl(link));
// Add seperator
if(c != 'Z')
Alphabet.Controls.Add(new LiteralControl(" | "));
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.