Programming Tips for .NET Guys !

1. How to handle single quote (‘) during insertion and updation ?

Suppose there is a text box in form and you want to handle single quote ( ‘ ) during insertion and updation.

string StrValue=this.TextBox1.Text;
StrValue=StrValue.Replace(“‘”,”””);

2. How to handle maximum length in multi line text box ?

Suppose there is a multi line text box in form and you want to handle maximum length during insertion and updation.

int MaxLength=this.TextBox1.Text.Length;
if(MaxLength>=100)
MaxLength=100;
string StrMaxLength=this.TextBox1.Text.SubString(0,MaxLength);

3. How to do date time search in string mode ?

Suppose there is a text box in form and you want to search a date in grid using text entered in text box.

DateTime ScheduledDate=Convert.ToDateTime(this.TextBox1.Text);
string StrScheduledDate= ScheduledDate.ToString(MM,dd,yyyy);