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 }); }
Path class
Suppose you have a specified path such as "C:/my files/abc.txt" and you want to access root of the specified path (Root is "C:/"). If your path does not contain root directory information then your path class method returns null value or empty string. For accessing root information use GetPathRoot( ) method of the Path class which is stored in System.IO namespace.Lets take an example
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace WindowsFormsApplication2
{
public partial class Form6 : Form
{
public Form6()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string path = textBox1.Text;
string getroot = Path.GetPathRoot(path);
label2.Text = "Your root directory is "+getroot;
}
}
}
.
Output
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace WindowsFormsApplication2
{
public partial class Form6 : Form
{
public Form6()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string path = textBox1.Text;
string getroot = Path.GetPathRoot(path);
label2.Text = "Your root directory is "+getroot;
}
}
}
Comments
Post a Comment