Sunday, July 14, 2013

get the current month and year in asp.net

Title:How to get current month and year in asp.net using c#.net

Description:
As per previous articles we have seen how get month and year using JQuery. Now i would like to explain and give the example on the same concept in c#.net.The C#.net provide the object "Date Time" which has some properties to get the retired data.As per our discussion i will use the two methods to get the current month and year.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
int year = DateTime.Now.Year;
int month = DateTime.Now.Month;
int date = (DateTime.Now.Day)+2;
Response.Write(year.ToString()+ month.ToString()+date.ToString());
}
}

No comments:

Bel