Friday, February 25, 2011

Formating DateTime

if u want to save with AM/PM

Example 1:
1. string strSecond = (System.DateTime.Now).ToString("dd-MMM-yyyy hh:mm tt");


if u want to save only date
2. string strSecond = (System.DateTime.Now).ToString("dd-MMM-yyyy ");


Example 2:
1. string strSecond = "25-01-2001"; (or)  "2011-01-25";.ToDateTime(strSecond ).ToString("dd-MMM-yyyy hh:mm tt");
     Convert

Make sure that u have to convert to DB the dateFormat from stringParam which we are sending.

Wednesday, February 23, 2011

Switch Local culture Language sample

if
{
string culture = string.Empty;
culture = Session["language"].ToString();//ddlLang.SelectedItem.Value;// Request.Form["ddlLang"];if (string.IsNullOrEmpty(culture)) culture = "Auto";
UICulture = culture;
Page.Culture = culture;
if (culture != "Auto")
{
CultureInfo ci = new CultureInfo(culture);
Thread.CurrentThread.CurrentCulture = ci;
Thread.CurrentThread.CurrentUICulture = ci;
}
}
(Session["language"] != null)