Monday, October 29, 2012

Convert String in Title Case

string asTitleCase = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(txt1.Text.ToLower());

It will return "This Is Blog" from "this is blog"

Monday, May 28, 2012

ASP.NET MVC Flexigrid sample

URL : http://www.codeproject.com/Articles/30588/ASP-NET-MVC-Flexigrid-sample

How to create an ASP.NET MVC sample using LINQ to SQL, Flexigrid for JQuery, and JSON.

Wednesday, February 1, 2012

String Methods()

IndexOf(): method in string Class in C# returns the index of the first occurrence of the specified substring.
Syntax:int string.IndexOf(string str)

Integer - If the parameter String occurred as a substring in the specified String
it returns position of the first character of the substring.
If it does not occur as a substring, -1 is returned.

Example:
"This is a test".IndexOf("Test") returns 10
"This is a test".IndexOf("vb") returns -1


Clone(): method creates and returns a copy of string object. The CSharp string Clone() method returns a reference to this instance of string.

string str = "Clone() Test";
string clonedString = null;
clonedString = (String)str.Clone();


Compare(): function compares two strings lexicographically . The comparison is based on the Unicode value of each character in the string.
Syntax: int string.Compare(string str1,string str2)

It returns an Integer indication lexical relationship between the two comprehends

Integer : returns less than zero, zero or greater than zero.
Less than zero : str1 is less than str2
zero : str1 is equal to str2
Greater than zero : str1 is greater than str2


Concat(): method Concatenates the two specified string and create a new string.
Syntax: string concat(string str1,string str2)

EndsWith(): method check if the Parameter String EndsWith the Specified String
Syntax: bool string.EndsWith(string suffix)

Equals(): method is to check the specified two String Object values are same or not
Syntax: bool string.Equals(string str1,string str2)

Insert(): method will insert a String in a specified index in the String instance.
Syntax: string string.Insert(int ind,string str)
"This is Test".Insert(8,"Insert ") returns "This is Insert Test"

TryParse(): method is using for determine whether a string is a valid representation of a specified numeric type or not. TryParse method that is implemented by all primitive numeric types and also by types such as DateTime and IPAddress.
Syntax: bool int.TryParse(string param , out int result)


Substring():

string input = "OneTwoThree";

string sub = input.Substring(0, 3);
//Output : One

string sub = input.Substring(3);
//Output : TwoThree

string sub = input.Substring(3, 3);
//Output : Two

string sub = input.Substring(0, input.Length - 5);
//Output : OneTwo

string CultureInfo(): The String Class is a sealed class , so you cannot inherit another class from the String class. ToTitleCase converts the first character of a word to uppercase and the rest of the characters to lowercase.

A neutral culture is specified by only the two-letter lowercase language code. For example, "fr" specifies the neutral culture for French, and "de" specifies the neutral culture for German.

System.Globalization.CultureInfo cultureInfo = _new System.Globalization.CultureInfo("en-US");

The CultureInfo class renders culture-specific information, such as the associated language, sublanguage, country/region, calendar, and cultural conventions. The following C# source code shows how to convert a string to Title Case.

string _str = null;
System.Globalization.CultureInfo cultureInfo = new System.Globalization.CultureInfo("en-US");
_str = cultureInfo.TextInfo.ToTitleCase("make first letter capital");
MessageBox.Show (_str);

Monday, January 23, 2012

ASP Menu Control Browser Comaptibility

Use this code to your master page where ASP Menu control is used.

At Form Load
Request.Browser.Adapters.Clear();