Feeds:
Posts
Comments

Archive for February, 2007

guideline for programmer

http://www.pragmaticprogrammer.com/ppbook/extracts/rule_list.html

Read Full Post »

IsDate in ASP.NET

public static bool IsDate(Object obj)
{
string strDate = obj.ToString();
try
{
DateTime dt = DateTime.Parse(strDate);
if((dt.Month!=System.DateTime.Now.Month) || (dt.Day<1&&dt.Day>31) || dt.Year!=System.DateTime.Now.Year)
return false;
else
return true;
}
catch
{
return false;
}
}

I have got another good solution form one forum according to my discussion with anotehr developer.
protected bool CheckDate(String date)
{
try
{
DateTime dt = DateTime.Parse(date); return true;
}
catch
{
return false;
}
}

Read Full Post »

IsNumeric in ASP.NET

public static bool IsNumeric(object value)
{
        try
        {
            int i = Convert.ToInt32(value.ToString());
            return true;
        }
        catch (FormatException)   
        {
            return false;
        }
}

Read Full Post »

isGuid in ASP.NET

static bool isGuid(string guid)
{
bool isValid = false;
Regex re = new Regex(@”^({){0,1}[0-9a-fA-F]{8}-[0-9a-fA-F]{4}- [0-9a-fA-F]{4}-[0-9a-fA-F]{4}- [0-9a-fA-F]{12}(}){0,1}$”, RegexOptions.IgnoreCase);
if (re.IsMatch(guid))
{
isValid = true;
}
return isValid;
}

Read Full Post »