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 }); }
If you want to get minute difference between two times then you should use TimeSpan Structure for that. First to create two DateTime object. Now, create difference between two dates using TimeSpan structure also get minutes using TotalMinutes property of TimeSpan structure.
runat="server">
<asp:Button ID="Button1"
runat="server"
BackColor="#FF33CC"
onclick="Button1_Click"
Text="Click"
Width="73px" />
<div>
<asp:Label ID="Label1"
runat="server"
BackColor="Yellow"
Text="Label"></asp:Label>
</div>
</form>
{
{
DateTime now = DateTime.Now;
Label1.Text = "now : " + now.ToString();
DateTime dateAfter4Hours = now.AddHours(4);
TimeSpan TS = dateAfter4Hours - now;
int minutes = (int)TS.TotalMinutes;
Label1.Text += "<br ><br />after four hours: ";
Label1.Text += dateAfter4Hours.ToString();
Label1.Text += "<br ><br />This is difference between to datetime object in minutes : ";
Label1.Text += minutes;
}
}
Code Generate the following output
Source Code
<form id="form1"runat="server">
<asp:Button ID="Button1"
runat="server"
BackColor="#FF33CC"
onclick="Button1_Click"
Text="Click"
Width="73px" />
<div>
<asp:Label ID="Label1"
runat="server"
BackColor="Yellow"
Text="Label"></asp:Label>
</div>
</form>
Code Behind
protected void Button1_Click(object sender, EventArgs e){
{
DateTime now = DateTime.Now;
Label1.Text = "now : " + now.ToString();
DateTime dateAfter4Hours = now.AddHours(4);
TimeSpan TS = dateAfter4Hours - now;
int minutes = (int)TS.TotalMinutes;
Label1.Text += "<br ><br />after four hours: ";
Label1.Text += dateAfter4Hours.ToString();
Label1.Text += "<br ><br />This is difference between to datetime object in minutes : ";
Label1.Text += minutes;
}
}
Code Generate the following output
Comments
Post a Comment