Thursday, February 7, 2013

JIT Compiler

Just In Time Compiler is responsible for Converting IL code to native code.

•Pre-JIT COMPILER
Pre-JIT compiles complete source code into native code in a single compilation cycle. This is done at the time of deployment of the application.
 
•Econo-JIT COMPILER:
Econo-JIT compiles only those methods that are called at runtime. However, these compiled methods are removed when they are not required.
 
•Normal-JIT COMPILER:
Normal-JIT compiles only those methods that are called at runtime. These methods are compiled the first time they are called, and then they are stored in cache. When the same methods are called again, the compiled code from cache is used for execution.

Wednesday, February 6, 2013

Export to Excel(Concatenate the row in case of BR)

When export to excel if some columns are displayed as new row then in the exported file it show the details in new row. This export will concatenate both the column in same row.

Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/vnd.ms-excel";
Response.AppendCookie(new HttpCookie("fileDownloadToken", exportToken.Value));
Response.AddHeader("content-disposition", "attachment;filename=ProjectResouces.xls");
string header = @" < html xmlns:x=""urn:schemas-microsoft-com:office:excel"" > 
< head >
< style >
< !--table
br {mso-data-placement:same-cell;}
tr {vertical-align:top;}
-- >
< /style >
< /head >
< body >";
Response.Write(header);

Response.Charset = "";
dgDetails.EnableViewState = false;
StringWriter sw = new StringWriter();
StringWriter headWrite = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
dgDetails.RenderControl(htw);
headWrite.Write("< table >  < /table >");
headWrite.WriteLine(sw);
Response.Write(headWrite.ToString());
string footer = "< /body> </HTML >";
Response.Write(footer);

Response.Flush();
Response.End();

Tuesday, February 5, 2013

Using Pivot in SQL

Empid EmpName EmpDay empStatus
1 Bikash 1 P
2 Bikash 2 P
3 Bikash 3 P
4 Bikash 4 A
5 Bikash 5 A
6 Bikash 6 P
7 Bikash 8 P
8 Rama Rao 1 P
9 Rama Rao 2 P
10 Rama Rao 6 P
11 Rama Rao 3 P
12 Rama Rao 7 P

SELECT EMPNAME,[1],[2],[3],[4],[5],[6],[7],[8],[9] FROM (SELECT EMPNAME,EMPDAY,EMPSTATUS FROM EMPTEST) X PIVOT (MAX(EMPSTATUS) FOR EMPDAY IN([1],[2],[3],[4],[5],[6],[7],[8],[9])) Y


EMPNAME 1 2 3 4 5 6 7 8 9
Bikash P P P A A P NULL P NULL
Rama Rao P P P NULL NULL P P P NULL

DECLARE @cols AS NVARCHAR(MAX)
DECLARE@query AS NVARCHAR(MAX)
 
SET @cols = (SELECT DISTINCT ',['+ CAST(EMPDAY AS VARCHAR(10)) +']' FROM EMPTEST FOR XML PATH(''))
SELECT @cols= SUBSTRING(@COLS,2,LEN(@cols))
  SET @query = 'SELECT EMPNAME,'+@cols+' FROM
(SELECT EMPNAME,EMPDAY,EMPSTATUS FROM EMPTEST) AS X
PIVOT (MAX(EMPSTATUS) FOR EMPDAY IN('+@cols+')) P'

EXEC (@query)

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();