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 }); }
Introduction
It is a simple example of array in c#, You can print element of array using for loop. Also print array element at specific position or index number. Simple, lower bound initialized from some value, where you want to print array element. Let's take an simple exampleSource code
<form id="form1" runat="server"><div>
<asp:Button ID="Button1" runat="server" Text="Button" Width="81px"
onclick="Button1_Click" />
</div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</form>
Business Logic Code
protected void Button1_Click(object sender, EventArgs e){
string[] fruits = new string[]
{
"papaya",
"Apple",
"Banana",
"Grapes",
"Orange",
"Pine-apple",
"Mango"
};
Label1.Text = "fruits array elements.........<br />";
for (int i = 0; i < fruits.Length; i++)
{
Label1.Text += fruits[i] + "<br />";
}
Label1.Text += "<br />fruits array elements [index size 1 to 5].........<br />";
for (int i = 1; i <= 5; i++)
{
Label1.Text += fruits[i] + "<br />";
}
Label1.Text += "<br />fruits array elements [index size 3 to 5].........<br />";
for (int i = 3; i <= 5; i++)
{
Label1.Text += fruits[i] + "<br />";
}
}
Comments
Post a Comment