Hi, 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(); }
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
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:
In an Index View use the below code: