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 }); }
In ASP.NET, you can connect multiple Events with same event handler. If you thing about it, this types of code reduce space complexity as well as time complexity. If you use events with separate events handler then take more time. Like
<div>
Both Event and methods name are same, both call to same handler.<br />
<asp:Button ID="Button1" runat="server" Text="First Button"
onclick="Button1_Click" /><br />
<asp:Button ID="Button2" runat="server" Text="Second Button" onclick="Button1_Click" /><br />
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
</div>
In my previous article, we have already discussed about it, which is how to determine which web server control is raised.
{
Button button = (Button)sender;
Label1.Text = button.Text;
}
<div>
Both Event and methods name are same, both call to same handler.<br />
<asp:Button ID="Button1" runat="server" Text="First Button"
onclick="Button1_Click" /><br />
<asp:Button ID="Button2" runat="server" Text="Second Button" onclick="Button1_Click" /><br />
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
</div>
In my previous article, we have already discussed about it, which is how to determine which web server control is raised.
Business Logic Code
protected void Button1_Click(object sender, EventArgs e){
Button button = (Button)sender;
Label1.Text = button.Text;
}
Comments
Post a Comment