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 }); }
Asp.Net MVC provides a way to write simple programming syntaxes and HTML Helpers convert them in to HTML at runtime to be simply open the pages at client end. These provides generates html and return result as a string.
Like other web form controls in Asp.Net, HTML helpers are used to modify HTML, but HTML Helpers does not have an event model/ view state as web form controls have. Programmer can use these helpers by using built in HTML property of the view that are in System.Web.Mvc.Html namespace. We can create our own Html helpers or use built-in provided in the specified namespace.
HTML helpers have methods for creating forms, rendering partial views, performing input validation etc. Here are some mostly used html helpers:
@Html.ActionLink(“Text to Display”, “Action-name”)
The first parameter is used to specify the text to be displayed for user and second parameter is used to specify the action-name to which user will redirect after click.
@using (Html.BeginForm())
{
//Other Html Helpers to complete the form
}
Parameters used
Like other web form controls in Asp.Net, HTML helpers are used to modify HTML, but HTML Helpers does not have an event model/ view state as web form controls have. Programmer can use these helpers by using built in HTML property of the view that are in System.Web.Mvc.Html namespace. We can create our own Html helpers or use built-in provided in the specified namespace.
HTML helpers have methods for creating forms, rendering partial views, performing input validation etc. Here are some mostly used html helpers:
HTML Links
These type of links are used to render an html link on the page, but in MVC they create a link to redirect on a particular action of the controller.@Html.ActionLink(“Text to Display”, “Action-name”)
The first parameter is used to specify the text to be displayed for user and second parameter is used to specify the action-name to which user will redirect after click.
HTML BeginForm
To place a form element on MVC, following syntax is used that will create an HTML form with some parameter values listed below.@using (Html.BeginForm())
{
//Other Html Helpers to complete the form
}
Parameters used
- ActionName: specify the name of action on which user will redirect
- ControllerName: name of controller in which action has written
- Route values: the values send as a parameter to action
- FormMethod: Type of form whether HttpPost or HttpGet
- Html attributes: used at run time like making readonly, applying css classes and more.
------------------------
- Html.Label()
- Html.TextBox()
- Password()
- RadioButton()
- CheckBox()
- BeginForm()
- TextArea()
- ListBox()
Comments
Post a Comment