Archive

Posts Tagged ‘C#’

CSS missing while using Response.Write in ASP.NET page

December 15th, 2009 Shyju No comments

When you are using response.write in your server side code behind page (C# or vb) for an ASP.NET page,The styles of page /CSS seems to be disappeared.Have you ever come across this problem ? Here is the solution to get rid of the probelm .

Instead of simply writing Response.Write, Use ” Page.ClientScript.RegisterStartupScript”

Ex : string strRenderImg=@”<img src=’company_logo1.gif’ align=’center’ />”;

Page.ClientScript.RegisterStartupScript(this.GetType(), “strRenderImg”, strRenderImg);

C# : How to Create a DateTime object from a string date

December 14th, 2009 Shyju No comments

In C#, Creating a DateTime object from a Date String is as follows.

string strStartDate=”11/11/2009″;

DateTime objStartDate = DateTime.Parse(strStartDate);

The objStartDate object,which is an object of DateTime class,  is now holding the date and u can use this object for all date manipulation functions

Always use DateTime wherever handling the dates instead of using String.DateTime gives u flexibility to work more on that like performing date manipulation

Categories: C# Tags: , , ,

Get User desktop folder path in C#

July 16th, 2008 Shyju No comments

How to Get the Path to the User desktop in C#.NET ? Here is the single line Code

string strPath=Environment.GetFolderPath(System.Environ

ment.SpecialFolder.DesktopDirectory).ToString();

OUTPUT looks like this..

F:\Documents and Settings\Shyju\Desktop