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 }); }
We have already discussed about that article , but today we add two months in current date time object , after that i will find how many days remaining from the current date and time. Lets take an simple example
<form id="form1"
runat="server">
<asp:Button ID="Button1"
runat="server"
onclick="Button1_Click"
Text="Click"
Width="71px" />
<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 today = DateTime.Today;
Label1.Text = "today : " + today.ToLongDateString();
DateTime twoMonthLater = today.AddMonths(2);
TimeSpan TS = twoMonthLater - today;
int days = TS.Days;
Label1.Text += "<br ><br />after two month: ";
Label1.Text += twoMonthLater.ToLongDateString();
Label1.Text += "<br ><br />This is difference between to datetime object in days:";
Label1.Text += days;
}
Code Generate the following output
<form id="form1"
runat="server">
<asp:Button ID="Button1"
runat="server"
onclick="Button1_Click"
Text="Click"
Width="71px" />
<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 today = DateTime.Today;
Label1.Text = "today : " + today.ToLongDateString();
DateTime twoMonthLater = today.AddMonths(2);
TimeSpan TS = twoMonthLater - today;
int days = TS.Days;
Label1.Text += "<br ><br />after two month: ";
Label1.Text += twoMonthLater.ToLongDateString();
Label1.Text += "<br ><br />This is difference between to datetime object in days:";
Label1.Text += days;
}
Code Generate the following output
Comments
Post a Comment