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 }); }
The most common method to get the data on server from client side. Submit button on the form can be used to post all the form data to be used further by programmer. Generally one form only have a single submit because of user want to post data only once.
To submit data in different ways programmer can use more than one submit button. A form can have multiple submit buttons as per the requirement of programmer. We can send the button’s name on the button click.
The action should have the same name of the button to get the value of clicked button. Suppose all the button’s have same name as submit as written below:
<input type = "submit" name = "btnsubmit" value= "submit1" />
<input type = "submit" name = "btnsubmit" value= "submit2" />
<input type = "submit" name = "btnsubmit" value= "submit3" />
Now in controller’s action the variable should be of string type and name as “submit” as below:
[HttpPost]
public ActionResult SubmitData(string btnSubmit)
{
If (btnSubmit == "submit1")
{
//code to execute
}
If (btnSubmit == "submit2")
{
//code to execute
}
If (btnSubmit == "submit3")
{
//code to execute
}
}
According to this code we can implement different functionality on each submit button with all the data posted on the form. These button will only post the data containing as input on the form and also inside the form element.
To submit data in different ways programmer can use more than one submit button. A form can have multiple submit buttons as per the requirement of programmer. We can send the button’s name on the button click.
The action should have the same name of the button to get the value of clicked button. Suppose all the button’s have same name as submit as written below:
<input type = "submit" name = "btnsubmit" value= "submit1" />
<input type = "submit" name = "btnsubmit" value= "submit2" />
<input type = "submit" name = "btnsubmit" value= "submit3" />
Now in controller’s action the variable should be of string type and name as “submit” as below:
[HttpPost]
public ActionResult SubmitData(string btnSubmit)
{
If (btnSubmit == "submit1")
{
//code to execute
}
If (btnSubmit == "submit2")
{
//code to execute
}
If (btnSubmit == "submit3")
{
//code to execute
}
}
According to this code we can implement different functionality on each submit button with all the data posted on the form. These button will only post the data containing as input on the form and also inside the form element.
Comments
Post a Comment