I want to show Components in a tabs , so first of all create few components. In this project we have three components, First View Component public class AllViewComponent : ViewComponent { private readonly UserManager<ApplicationUser> _userManager; public AllViewComponent(UserManager<ApplicationUser> userManager) { _userManager = userManager; } public async Task<IViewComponentResult> InvokeAsync() { List<StudentViewModel> allUsers = new List<StudentViewModel>(); var items = await _userManager.Users.ToListAsync(); foreach (var item in items) { allUsers.Add(new StudentViewModel {Id=item.Id, EnrollmentNo = item.EnrollmentNo, FatherName = item.FatherName, Name = item.Name, Age = item.Age, Birthdate = item.Birthdate, Address = item.Address, Gender = item.Gender, Email = item.Email }); }
Getting started -Introduction
MVC is a framework used for building web application using latest and somewhat different approach. According to this architecture, whole application divides in to three part i.e. Model, View and Controller which is also the pronunciation stands for MVC.- Model: keeps the application core. It includes some classes written to interact with database.
- View: how is to be displayed on the page? falls into this category.
- Controller: what is to be transfer on the views? falls into this category.
More about MVC can be easily read through here, but we will start some practical work here. I suppose every DotNet programmer knows about Visual Studio. Let’s start with creating a new MVC application using below steps. Step 1. Create new project and select ASP.NET MVC 4 Web Application under the Web categories. Step 2. Change the directory where solution will exist, it takes default if not changed and click on OK button. Step 3. It will asks about the type of application e.g. empty, internet, intranet etc. listed in the image provided. Select Internet application because it loads the default controllers and their actions with authentication.
Through this we can only creating application, on the next we will code with empty MVC application. Step 4. Congratulation, you have successfully created a new MVC 4 application. Now run this with F5 or from Start debugging option in DEBUG menu. When it run it looks like the below image. In the browser’s address i.e. http://localhost:port/ localhost is the computer which is running that application at that time, means the client machine and the port is the number assigned for that application.
Comments
Post a Comment