Monday, 21 May 2012

Validating CheckboxList using Jquery

Below script is useful when you want to validate the checkboxlist control.
You just need to add below function on page.

<script language="javascript" type="text/javascript">
function CheckBoxList1_Validation(sender, args)
{
args.IsValid = false;
var cnt = $("#CheckBoxList1 input:checked").length;
args.IsValid = (cnt >= 3);
}
</script>


Post By : Dipen Shah
Blog By : Dipen Shah
Stay Tuned...

Sunday, 20 May 2012

Self Join

A self-join is simply a normal SQL join that joins one table to itself. This is accomplished by using table name aliases to give each instance of the table a separate name. Joining a table to itself can be useful when you want to compare values in a column to other values in the same column.
 A join in which records from a table are combined with other records from the same table when there are matching values in the joined fields. A self-join can be an inner join or an outer join. A table is joined to itself based upon a field or combination of fields that have duplicate data in different records. The data-type of the inter-related columns must be of the same type or needs to cast them in same type.

Examples:

USE ProductManagement
Go
SELECT DISTINCT pv1.ProductID, pv1.CategoryID
FROM dbo.Products pv1
INNER JOIN dbo.Products pv2
ON pv1.ProductID = pv2.ProductID
AND pv1.CategoryID = pv2.CategoryID
ORDER BY pv1.ProductID


Post By : Urvish Patel
Blog By : Dipen Shah
Stay tuned for more... 

Saturday, 19 May 2012

Get File Name Without Extention

Below code in asp.net get the filename without extention.

DirectoryInfo directoryInfo = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.SendTo)); directoryInfo.GetFiles().Select(file => Path.GetFileNameWithoutExtension(file.Name)).ToArray();

Posted By : Dipen Shah 
Stay Tuned...

Differance Between CLR, CTS, CLS

What is a CLR? Full form of CLR is Common Language Runtime and it forms the heart of the .NET framework.All Languages have runtime and its the responsibility of the runtime to take care of the code execution of the program. Java has Java Virtual Machine, Similarly .NET has CLR.The responsibilities of CLR are Garbage Collection, Code Access Security, Code Verification, IL( Intermediate language ).
What is a CTS?
In order that two language communicate smoothly CLR has CTS (Common Type System). In order that two different languages can communicate Microsoft introduced Common Type System. So “Integer” datatype in VB6 and “int” datatype in C++ will convert it to System.int32 which is datatype of CTS.
What is a CLS(Common Language Specification)? This is a subset of the CTS which all .NET languages are expected to support.Microsoft has defined CLS which are nothing but guidelines that language to follow so that it can communicate with other .NET languages in a seamless manner.
Post By : Dipen Shah Stay Tuned

Always match datatypes in code with the columns in the database

It's important to make sure that your datatypes match across all layers in your application. For example, if a column's datatype is VarChar(50), you should have the code in queries and stored procedures use local variables of the same datatype.

Similarly, the ADO.NET code in the data layer should specify the same datatype and length.


Posted By : Dipen Shah
Stay Tuned