Thursday, January 5, 2012

Show date And Time in many format

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class CurrentDate : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = System.DateTime.Now.ToString();
Label3.Text = System.DateTime.Now.ToLongDateString();
Label4.Text = System.DateTime.Now.ToLongTimeString();
Label5.Text = System.DateTime.Now.ToShortDateString();
Label6.Text = System.DateTime.Now.ToShortTimeString();
}
}

Find The Host name

private string GetIP()
{
string strHostName = " " ;
strHostName = System.Net.Dns.GetHostName();
return strHostName;
}
And write the code this secssion
protected void Page_Load(object sender, EventArgs e)
TextBox4.Text =GetIP();