All,
How to create a mask to the DateTime field in the propertygrid such a way that, user can enter only in that format. For example, by default "dd/mm/yyyy" should be displayed in the DateTime field. When user key in numbers, the numbers should replace the respective palces. Ofcourse, user can give input from DateTime picker also.
Please, suggest me by giving code snippets or sample source code. Thanks in advance.
Bijayani BaijayantiPosted Jun 23, 2010, 5:09 AM
Provided below are code samples written in C# to format an input as per SharePoint DateTime field.
/* -- Format for Date Only Field -- */
private static String ToSPDate(String strDt)
{
if (strDt == String.Empty)
return strDt;
else
return (Convert.ToDateTime(strDt)).ToString("yyyy-MM-dd");
}
/* -- Format for DateTime Field -- */
private static String ToSPDateTime(String strDt)
{
if (strDt == String.Empty)
return strDt;
else
return (Convert.ToDateTime(strDt)).ToString("yyyy-MM-ddTHH:mm:ssZ");
}
Thanks,
Bijayani
SharePoint Development
kumar pPosted Feb 9, 2009, 3:03 AM
all,
Can we customize the propertygrid such a way that it can fit in my needs???
kumar pPosted Feb 8, 2009, 6:27 AM
First of all, Thanks for the response.......
Actually, Im using C# and .NET......I tried as you said. But, I did not get expected result.
Please, If you have a source code, share with me. Thank you.......
Scott LyslePosted Feb 8, 2009, 12:55 AM
Scott LyslePosted Feb 8, 2009, 12:55 AM