You can dynamically create menu control in asp.net mvc by using ViewBag or ViewData properties. For eg: Create a action method (Index) in a controller as given below:
public ActionResult Index() { List<string> hobby = new List<string>(); hobby.Add("Cricket"); hobby.Add("Football"); hobby.Add("Tennis"); ViewBag.Hobbies = hobby; //hobby is List return View(); }
ravi kumar
01-Nov-2011Chris Anderson
01-Nov-2011You can dynamically create menu control in asp.net mvc by using ViewBag or ViewData properties.
For eg:
Create a action method (Index) in a controller as given below:
In an Index View use the below code: