<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6802100233572382458</id><updated>2012-02-28T01:12:40.505-08:00</updated><title type='text'>Narsimha.Puranik</title><subtitle type='html'>This is my personal blog....</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>55</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-6074944819310457637</id><published>2012-02-13T10:08:00.000-08:00</published><updated>2012-02-13T10:08:00.094-08:00</updated><title type='text'>SQL SERVER – List All the Tables for All Databases Using System Tables</title><content type='html'>&lt;b&gt;sp_msforeachdb 'select "?" AS db, * from [?].sys.tables'&lt;/b&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-6074944819310457637?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/6074944819310457637/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2012/02/sql-server-list-all-tables-for-all.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/6074944819310457637'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/6074944819310457637'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2012/02/sql-server-list-all-tables-for-all.html' title='SQL SERVER – List All the Tables for All Databases Using System Tables'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-4256208753692768190</id><published>2012-02-02T10:37:00.002-08:00</published><updated>2012-02-02T10:53:21.514-08:00</updated><title type='text'>Table-Valued Parameters in Sql Server</title><content type='html'>This is a new feature intorduced in Sql Server 2008. Table-Valued Parameters provides option for the Client Applications to pass multiple rows of Data to Stored Procedure.&lt;br /&gt;&lt;br /&gt;Prior to this, if we were needed to pass multiple rows of Data from client application to Sql Server, then we use to model the input data as xml and pass it to the stored procedure and in Stored Procedure convert this xml to a table variable/temporary table.&lt;br /&gt;&lt;br /&gt;In this article we will not only go over this Table-Valued Parameter we will also understand how to call the Stored Procedure with Table-Valued Parameter from Sql Server and C# .Net Code.&lt;br /&gt;&lt;br /&gt;Table-Valued User Defined Data Type&lt;br /&gt;First we need to Create a User Defined Table Type which can be reused in multiple stored procedures as input table parameter data type.&lt;br /&gt;&lt;br /&gt;CREATE TYPE dbo.CustomerTableType AS TABLE&lt;br /&gt;( &lt;br /&gt;[CustomerID] INT,&lt;br /&gt;[Name]  VARCHAR(50)&lt;br /&gt;)&lt;br /&gt;GOStored Procedure with Table-Valued input Parameter&lt;br /&gt;Now let us create a simple stored procedure which takes CustomerType User Definde Table Type which we have created previously&lt;br /&gt;&lt;br /&gt;CREATE PROCEDURE dbo.GetCustomerDetails&lt;br /&gt;(&lt;br /&gt;@Customers AS dbo.CustomerTableType READONLY&lt;br /&gt;)&lt;br /&gt;AS&lt;br /&gt;BEGIN&lt;br /&gt;SET NOCOUNT ON&lt;br /&gt;&lt;br /&gt;SELECT *&lt;br /&gt;FROM @Customers&lt;br /&gt;ENDUsing Stored Procedure With Table Valued Parameter in Sql Server&lt;br /&gt;&lt;br /&gt;Declare @CustomerDetails As dbo.CustomerTableType&lt;br /&gt;Insert Into @CustomerDetails Values(1,'Narsimha'),&lt;br /&gt;(2,'Mithun'),&lt;br /&gt;(3,'Sachin') &lt;br /&gt;&lt;br /&gt;Exec dbo.GetCustomerDetails @CustomerDetails&lt;br /&gt;GO&lt;br /&gt;Result:&lt;br /&gt;CustomerID   Name&lt;br /&gt;----------- ------------&lt;br /&gt;1           Narsimha&lt;br /&gt;2           Mithun&lt;br /&gt;3           Sachin&lt;br /&gt;&lt;br /&gt;Calling Stored Procedure with Table Valued Parameter from C# Code&lt;br /&gt;Below is a sample C# Code example which calls the GetCustomerDetails Stored Procedure with Table-Valued Parameter which is created in the previous section.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using System.Data.SqlClient;&lt;br /&gt;namespace TableValuedParameter&lt;br /&gt;{&lt;br /&gt;class Program&lt;br /&gt;{&lt;br /&gt;static void Main(string[] args)&lt;br /&gt;{&lt;br /&gt;//Create and open a connection object&lt;br /&gt;SqlConnection conn = new SqlConnection(&lt;br /&gt;"ENTER A VALID CONNECTION STRING");&lt;br /&gt;conn.Open();&lt;br /&gt;&lt;br /&gt;//Create a command object specify the stored procedure&lt;br /&gt;SqlCommand cmd = new SqlCommand("dbo.GetCustomerDetails", conn);&lt;br /&gt;cmd.CommandType = CommandType.StoredProcedure;&lt;br /&gt;//PrePare the rows of Data to be Passed to the Stored Procedure            &lt;br /&gt;DataTable dataTable = new DataTable("Customer");&lt;br /&gt;dataTable.Columns.Add("Id", typeof(Int32));&lt;br /&gt;dataTable.Columns.Add("Name", typeof(string));&lt;br /&gt;dataTable.Rows.Add(1, "Narsimha");&lt;br /&gt;dataTable.Rows.Add(2, "Mithun");&lt;br /&gt;dataTable.Rows.Add(3, "Sachin");&lt;br /&gt;&lt;br /&gt;//Add the Table-Valued Parameter value to the Command Object            &lt;br /&gt;SqlParameter param = new SqlParameter("@Customers", dataTable);&lt;br /&gt;param.SqlDbType = SqlDbType.Structured;           &lt;br /&gt;cmd.Parameters.Add(param);&lt;br /&gt;// Execute the command&lt;br /&gt;SqlDataReader rdr = cmd.ExecuteReader();&lt;br /&gt;// iterate through results, printing each record to the console&lt;br /&gt;while (rdr.Read())&lt;br /&gt;{&lt;br /&gt;Console.WriteLine("Employee ID: {0} Name: {1}"&lt;br /&gt;,rdr["CustomerID"],rdr["Name"]);&lt;br /&gt;}&lt;br /&gt;conn.Close();&lt;br /&gt;rdr.Close();&lt;br /&gt;Console.ReadKey();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Result Seen on the console: &lt;br /&gt;Employee ID: 1 Name: Narsimha&lt;br /&gt;Employee ID: 2 Name: Mithun&lt;br /&gt;Employee ID: 3 Name: Sachin&lt;br /&gt;&lt;br /&gt;EXECUTE Permission ON Table Type User Defined Type: Eventhough we have Execute permission on the Stored Procedure, we still need to give Execute permission on the Table Type User Defined Type. Below is the syntax for granting execute persmission on the Table Type User Defined Type&lt;br /&gt;&lt;br /&gt;GRANT EXECUTE ON TYPE::dbo.CustomerTableType TO UserName&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-4256208753692768190?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/4256208753692768190/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2012/02/table-valued-parameters-in-sql-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/4256208753692768190'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/4256208753692768190'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2012/02/table-valued-parameters-in-sql-server.html' title='Table-Valued Parameters in Sql Server'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-6108133737278153267</id><published>2012-02-02T10:32:00.001-08:00</published><updated>2012-02-02T10:42:38.107-08:00</updated><title type='text'>New Features in Sql Server 2008</title><content type='html'>Following are the some of the new features of the Sql Server 2008 which are very helpful to the Sql Developers&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1) Table-Valued Parameters in Sql Server: provides option for the Client Applications to pass multiple rows of Data to Sql Server.&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;Prior to this, if we were needed to pass multiple rows of Data from client application to Sql Server, then we use to model the input data as xml /comma separated values and pass it to the stored procedure and in Stored Procedure convert this xml/comma separated values to a table variable/temporary table.&lt;br /&gt;&lt;br /&gt;You can find detailed information on the Table-Valued Parameters and also on calling Stored Procedure with Table-Valued Parameter from Sql Server and C# .Net Code @ http://beginsql.wordpress.com/2011/09/09/table-valued-parameters-in-sql-server/&lt;br /&gt;&lt;br /&gt;&lt;b&gt;2) Variable declaration allows initialization:&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;Prior to Sql Server 2008 to initialize a variable, we needed to first declare the variable and then we can initialize it by using SET/SELECT statement as shown below:&lt;br /&gt;&lt;br /&gt;DECLARE @COUNT INT&lt;br /&gt;SET @COUNT =100Now in Sql Server 2008 Variable declaration allows initialization similar to the one we do in C#. Now instead of writing two statements, we can write a single statement as below:&lt;br /&gt;&lt;br /&gt;DECLARE @COUNT INT =1003) Insert multiple rows using single INSERT Statement&lt;br /&gt;&lt;br /&gt;To understand this feature first create an Employee Table by using the below script:&lt;br /&gt;&lt;br /&gt;CREATE TABLE DBO.Employee (  Id INT,  Name VARCHAR(50) )Prior to Sql Server 2008, to insert multiple records we use to write statements like below:&lt;br /&gt;&lt;br /&gt;INSERT INTO dbo.Employee VALUES(1,'Narsimha')&lt;br /&gt;INSERT INTO dbo.Employee VALUES(2,'Mithun')&lt;br /&gt;INSERT INTO dbo.Employee VALUES(3,'Sachin')Now in Sql Server 2008 we can accomplish the same by writing script like below:&lt;br /&gt;&lt;br /&gt;INSERT INTO dbo.Employee VALUES(1,'Narsimha') ,(2,'Mithun') ,(3,'Sachin')&lt;br /&gt;&lt;br /&gt;&lt;b&gt;4) Arithematic Assignment Operators&lt;br /&gt;&lt;/b&gt;Now Sql Server 2008 also supports the Arithematic Assignment Operators like the below ones:&lt;br /&gt;&lt;br /&gt;Operator Usage            Description&lt;br /&gt;+=       SET @x+=@y       Same as: SET @x = @x + @y&lt;br /&gt;-=       SET @x-=@y       Same as: SET @x = @x - @y&lt;br /&gt;*=       SET @x*=@y       Same as: SET @x = @x * @y&lt;br /&gt;/=       SET @x/=@y       Same as: SET @x = @x / @y&lt;br /&gt;%=       SET @x%=@y       Same as: SET @x = @x % @yExample:&lt;br /&gt;&lt;br /&gt;DEClARE @x INT =2 ,@y INT = 2&lt;br /&gt;SET @x+=@y &lt;br /&gt;SELECT @x as x,@y as y&lt;br /&gt;Result:&lt;br /&gt;x           y&lt;br /&gt;----------- -----------&lt;br /&gt;4           25) &lt;br /&gt;&lt;br /&gt;&lt;b&gt;MERGE Statement&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;Merge statement is one of the interesting T-Sql enhancements of Sql Server 2008. With Merge statement we can very efficiently perform multiple DML operations like INSERT, UPDATE and DELETE on the target table data based on Source table data and the join condition specified between them.&lt;br /&gt;&lt;br /&gt;You can find detailed information on MERGE Statement @ http://beginsql.wordpress.com/2011/09/24/merge-statemen…ql-server-2008/&lt;br /&gt;&lt;br /&gt;&lt;b&gt;6) Sparse Column&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;Sparse Column is one more new feature introduced in SQL SERVER 2008. Storing a null value in a sparse column doesn’t take any space, but storing a non-null value in sparse column takes 4 bytes extra space than the non-sparse columns of the same data type.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-6108133737278153267?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/6108133737278153267/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2012/02/new-features-in-sql-server-2008.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/6108133737278153267'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/6108133737278153267'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2012/02/new-features-in-sql-server-2008.html' title='New Features in Sql Server 2008'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-7085543877765642491</id><published>2012-02-02T10:31:00.003-08:00</published><updated>2012-02-02T10:31:54.871-08:00</updated><title type='text'>Difference between DateTime and DateTime2 DataType</title><content type='html'>DateTime2 is the new Data Type introduced in Sql Server 2008 for storing Date and Time value. As per MSDN, Microsoft Suggests to use this new Data Type for new work instead of DateTime. Following table summarizes some of the major difference between this new DateTime2 and the old DateTime Data Type.&lt;br /&gt;&lt;br /&gt; DateTime DateTime2[(n)] &lt;br /&gt;Min Value 1753-01-01 00:00:00 0001-01-01 00:00:00 &lt;br /&gt;Max Value 9999-12-31 23:59:59.997 9999-12-31 23:59:59.9999999 &lt;br /&gt;Storage Size 8 Bytes 6 to 8 bytes&lt;br /&gt;Note: Parameter n is optional and if it is not specified then fractional seconds precision is 7 digit and it can be from 0 to 7 digit.&lt;br /&gt;For fractional seconds precision &lt;3, takes 6 bytesFor fractional seconds precision 3 or 4 it will take 7 bytesFor fractional seconds precision &gt;4 it will take 8 bytes &lt;br /&gt;Usage Declare @now datetime Declare @now datetime2(7) &lt;br /&gt;Compliance Is not an ANSI/ISO compliant Is an ANSI/ISO compliant &lt;br /&gt;Current Date and Time function GetDate() – It returns DB Current Date and Time of DateTime Data Type&lt;br /&gt;Example: SELECT GETDATE()&lt;br /&gt;Result: 2011-09-16 13:23:18.767 SYSDATETIME()- It returns DB Current Date and Time of DateTime2 Data Type&lt;br /&gt;Example: SELECT SYSDATETIME()&lt;br /&gt;Result: 2011-09-16 13:23:18.7676720 &lt;br /&gt;+/- days WORKS&lt;br /&gt;Example: DECLARE @nowDateTime DATETIME = GETDATE()&lt;br /&gt;SELECT @nowDateTime + 1&lt;br /&gt;Result: 2011-09-17 13:44:31.247 FAILS – Need to use only DateAdd function&lt;br /&gt;Example: DECLARE @nowDateTime2 DATETIME2= SYSDATETIME()&lt;br /&gt;SELECT @nowDateTime2+1&lt;br /&gt;Result: Msg 206, Level 16, State 2, Line 2&lt;br /&gt;Operand type clash: datetime2 is incompatible with int &lt;br /&gt;&lt;br /&gt;DateTime2 with fractional seconds precision of 3 is same as datetime data type. And DateTime(3) uses 7 bytes of storage instead of 8 byte which old datetime datatype uses and it also provides higer date range (i.e. 0001-01-01 to 9999-12-31 ) compared to DateTime data type. Now let us see this with an example:&lt;br /&gt;&lt;br /&gt;DECLARE @nowDateTime DATETIME = GETDATE(),&lt;br /&gt;        @nowDateTime2 DATETIME2(3)= SYSDATETIME()&lt;br /&gt;&lt;br /&gt;SELECT DATALENGTH(@nowDateTime) 'DateTime Storage Size' ,&lt;br /&gt;       DATALENGTH(@nowDateTime2) 'DateTime2(3) Storage Size'&lt;br /&gt;&lt;br /&gt;Result:&lt;br /&gt;DateTime Storage Size  DateTime2 Storage Size&lt;br /&gt; --------------------- ----------------------&lt;br /&gt; 8                     7&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-7085543877765642491?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/7085543877765642491/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2012/02/difference-between-datetime-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/7085543877765642491'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/7085543877765642491'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2012/02/difference-between-datetime-and.html' title='Difference between DateTime and DateTime2 DataType'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-4011549147108504473</id><published>2012-02-02T10:31:00.001-08:00</published><updated>2012-02-02T10:31:24.733-08:00</updated><title type='text'>Merge Statement in Sql Server 2008</title><content type='html'>Merge statement is one of the interesting T-Sql enhancements of Sql Server 2008. With Merge statement we can very efficiently perform multiple DML operations like INSERT, UPDATE and DELETE on the target table data based on Source table data and the join condition specified between them.&lt;br /&gt;&lt;br /&gt;This feature is very useful in a scenario where we want to synchronize the data in the target table with source table data. In earlier versions of sql server to achieve this synchronization we would have scanned the source and target tables multiple times(i.e. ones for inserting the new records , second time for updating the matching records and third time for deleting the records in the destination table which are not present in the source table), but with Merge statement we can achieve all this with single statement and with only one time looking-up of the source and target tables.&lt;br /&gt;&lt;br /&gt;Let us understand the Merge statement with a simple example.&lt;br /&gt;&lt;br /&gt;First create a Source Table with Sample Data:&lt;br /&gt;&lt;br /&gt;CREATE TABLE dbo.EmployeeSource(Id INT, Name VARCHAR(50))&lt;br /&gt;GO&lt;br /&gt;INSERT INTO dbo.EmployeeSource&lt;br /&gt;VALUES(1,'Basavaraj Biradar') ,  &lt;br /&gt;  (3,'Monty')&lt;br /&gt;GO&lt;br /&gt;SELECT * FROM dbo.EmployeeSource WITH(NOLOCK)&lt;br /&gt;GO&lt;br /&gt;--Source Table Data&lt;br /&gt;Id Name&lt;br /&gt;1  Basavaraj Biradar&lt;br /&gt;3  MontyNow create a Target Table with Sample Data:&lt;br /&gt;&lt;br /&gt;CREATE TABLE dbo.EmployeeTarget(Id INT, Name VARCHAR(50))&lt;br /&gt;GO&lt;br /&gt;INSERT INTO dbo.EmployeeTarget&lt;br /&gt;VALUES(1,'Basavaraj') ,&lt;br /&gt;  (2,'Shashank')&lt;br /&gt;GO&lt;br /&gt;SELECT * FROM dbo.EmployeeTarget WITH(NOLOCK)&lt;br /&gt;GO&lt;br /&gt; --Target Table Data&lt;br /&gt;Id Name&lt;br /&gt;1  Basavaraj&lt;br /&gt;2  ShashankNow Syncronize the target table with source table data using the below Merge statement:&lt;br /&gt;&lt;br /&gt;MERGE dbo.EmployeeTarget AS T&lt;br /&gt;USING dbo.EmployeeSource AS S&lt;br /&gt; ON T.Id = S.Id&lt;br /&gt;WHEN MATCHED THEN -- Matching Employee record&lt;br /&gt;  UPDATE SET T.NAME = S.NAME&lt;br /&gt;WHEN NOT MATCHED BY TARGET THEN&lt;br /&gt;-- Employee record presnet in Source but not in target&lt;br /&gt;  INSERT (Id, Name)&lt;br /&gt;  VALUES (S.Id, S.Name)&lt;br /&gt;WHEN NOT MATCHED BY SOURCE THEN&lt;br /&gt;-- Employee record present in destination but not in source&lt;br /&gt;   DELETE;Target table data after executing the above Merge statement:&lt;br /&gt;&lt;br /&gt;SELECT * FROM dbo.EmployeeTarget WITH(NOLOCK)&lt;br /&gt;GO&lt;br /&gt; --Target Table Data&lt;br /&gt;Id Name&lt;br /&gt;1  Basavaraj Biradar&lt;br /&gt;3  Monty&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-4011549147108504473?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/4011549147108504473/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2012/02/merge-statement-in-sql-server-2008.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/4011549147108504473'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/4011549147108504473'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2012/02/merge-statement-in-sql-server-2008.html' title='Merge Statement in Sql Server 2008'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-2041807945293955450</id><published>2011-11-06T21:36:00.000-08:00</published><updated>2011-11-06T21:36:28.931-08:00</updated><title type='text'>FileUpload Save Images in Database in ASP.NET C# VB.NET</title><content type='html'>In this example i am Uploading Images using FileUpload Control and saving or storing them in SQL Server database in ASP.NET with C# and VB.NET.&lt;br /&gt;&lt;br /&gt;Database is having a table named Images with three columns.&lt;br /&gt;1. ID Numeric Primary key with Identity Increment.&lt;br /&gt;2. ImageName Varchar to store Name of Image.&lt;br /&gt;3. Image Image to store image in binary format.&lt;br /&gt;&lt;br /&gt;Using C#.Net&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;protected void btnUpload_Click(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt; string strImageName = txtName.Text.ToString();&lt;br /&gt; if (FileUpload1.PostedFile != null &amp;&amp; &lt;br /&gt;     FileUpload1.PostedFile.FileName != "")&lt;br /&gt;  {&lt;br /&gt;   byte[] imageSize = new byte&lt;br /&gt;                 [FileUpload1.PostedFile.ContentLength];&lt;br /&gt;  HttpPostedFile uploadedImage = FileUpload1.PostedFile;&lt;br /&gt;  uploadedImage.InputStream.Read&lt;br /&gt;     (imageSize, 0, (int)FileUpload1.PostedFile.ContentLength);&lt;br /&gt;&lt;br /&gt; // Create SQL Connection &lt;br /&gt;  SqlConnection con = new SqlConnection();&lt;br /&gt;  con.ConnectionString = ConfigurationManager.ConnectionStrings&lt;br /&gt;                         ["ConnectionString"].ConnectionString;&lt;br /&gt;&lt;br /&gt; // Create SQL Command &lt;br /&gt;&lt;br /&gt; SqlCommand cmd = new SqlCommand();&lt;br /&gt; cmd.CommandText = "INSERT INTO Images(ImageName,Image)" +&lt;br /&gt;                   " VALUES (@ImageName,@Image)";&lt;br /&gt; cmd.CommandType = CommandType.Text;&lt;br /&gt; cmd.Connection = con;&lt;br /&gt;&lt;br /&gt; SqlParameter ImageName = new SqlParameter&lt;br /&gt;                     ("@ImageName", SqlDbType.VarChar, 50);&lt;br /&gt; ImageName.Value = strImageName.ToString();&lt;br /&gt; cmd.Parameters.Add(ImageName);&lt;br /&gt;&lt;br /&gt; SqlParameter UploadedImage = new SqlParameter&lt;br /&gt;               ("@Image", SqlDbType.Image, imageSize.Length);&lt;br /&gt; UploadedImage.Value = imageSize;&lt;br /&gt; cmd.Parameters.Add(UploadedImage);&lt;br /&gt; con.Open();&lt;br /&gt; int result = cmd.ExecuteNonQuery();&lt;br /&gt; con.Close();&lt;br /&gt; if (result &gt; 0)&lt;br /&gt; lblMessage.Text = "File Uploaded";&lt;br /&gt; GridView1.DataBind();&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Using VB.Net&lt;br /&gt;&lt;br /&gt;Protected Sub btnUpload_Click&lt;br /&gt;(ByVal sender As Object, ByVal e As EventArgs)&lt;br /&gt;&lt;br /&gt;    Dim strImageName As String = txtName.Text.ToString()&lt;br /&gt;    If FileUpload1.PostedFile IsNot Nothing AndAlso &lt;br /&gt;       FileUpload1.PostedFile.FileName &lt;&gt; "" Then&lt;br /&gt;&lt;br /&gt;        Dim imageSize As Byte() = New Byte&lt;br /&gt;          (FileUpload1.PostedFile.ContentLength - 1) {}&lt;br /&gt;&lt;br /&gt;        Dim uploadedImage__1 As HttpPostedFile = &lt;br /&gt;                                 FileUpload1.PostedFile&lt;br /&gt;&lt;br /&gt;        uploadedImage__1.InputStream.Read(imageSize, 0, &lt;br /&gt;              CInt(FileUpload1.PostedFile.ContentLength))&lt;br /&gt;        &lt;br /&gt;        ' Create SQL Connection &lt;br /&gt;        Dim con As New SqlConnection()&lt;br /&gt;        con.ConnectionString = &lt;br /&gt;                 ConfigurationManager.ConnectionStrings&lt;br /&gt;                  ("ConnectionString").ConnectionString&lt;br /&gt;        &lt;br /&gt;        ' Create SQL Command &lt;br /&gt;        &lt;br /&gt;        Dim cmd As New SqlCommand()&lt;br /&gt;        cmd.CommandText = "INSERT INTO Images&lt;br /&gt;           (ImageName,Image) VALUES (@ImageName,@Image)"&lt;br /&gt;        cmd.CommandType = CommandType.Text&lt;br /&gt;        cmd.Connection = con&lt;br /&gt;        &lt;br /&gt;        Dim ImageName As New SqlParameter&lt;br /&gt;                  ("@ImageName", SqlDbType.VarChar, 50)&lt;br /&gt;        ImageName.Value = strImageName.ToString()&lt;br /&gt;        cmd.Parameters.Add(ImageName)&lt;br /&gt;        &lt;br /&gt;        Dim UploadedImage__2 As New SqlParameter&lt;br /&gt;            ("@Image", SqlDbType.Image, imageSize.Length)&lt;br /&gt;        UploadedImage__2.Value = imageSize&lt;br /&gt;        cmd.Parameters.Add(UploadedImage__2)&lt;br /&gt;        con.Open()&lt;br /&gt;        Dim result As Integer = cmd.ExecuteNonQuery()&lt;br /&gt;        con.Close()&lt;br /&gt;        If result &gt; 0 Then&lt;br /&gt;            lblMessage.Text = "File Uploaded"&lt;br /&gt;        End If&lt;br /&gt;        GridView1.DataBind()&lt;br /&gt;    End If&lt;br /&gt;End Sub&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-2041807945293955450?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/2041807945293955450/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2011/11/fileupload-save-images-in-database-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/2041807945293955450'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/2041807945293955450'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2011/11/fileupload-save-images-in-database-in.html' title='FileUpload Save Images in Database in ASP.NET C# VB.NET'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-7091946728742866944</id><published>2011-11-06T21:23:00.000-08:00</published><updated>2011-11-06T21:23:19.400-08:00</updated><title type='text'>Programattically render pdf from ReportViewer</title><content type='html'>Dim warnings As Warning() = Nothing&lt;br /&gt;Dim streamids As String() = Nothing&lt;br /&gt;Dim mimeType As String = Nothing&lt;br /&gt;Dim encoding As String = Nothing&lt;br /&gt;Dim extension As String = Nothing&lt;br /&gt;Dim bytes As Byte()&lt;br /&gt;&lt;br /&gt;'First delete existing file&lt;br /&gt;Dim filepath As String = FolderLocation &amp; "PCSummary.PDF"&lt;br /&gt;File.Delete(filepath)&lt;br /&gt;'Then create new pdf file&lt;br /&gt;bytes = ReportViewer1.LocalReport.Render("PDF", Nothing, mimeType, _&lt;br /&gt;encoding, extension, streamids, warnings)&lt;br /&gt;Dim fs As New FileStream(FolderLocation &amp; "PCSummary.PDF", FileMode.Create)&lt;br /&gt;fs.Write(bytes, 0, bytes.Length)&lt;br /&gt;fs.Close()&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-7091946728742866944?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/7091946728742866944/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2011/11/programattically-render-pdf-from.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/7091946728742866944'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/7091946728742866944'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2011/11/programattically-render-pdf-from.html' title='Programattically render pdf from ReportViewer'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-1774155525575835830</id><published>2011-10-27T12:38:00.000-07:00</published><updated>2011-10-27T12:40:07.494-07:00</updated><title type='text'>Upload &amp; Download Files with FTP</title><content type='html'>&lt;b&gt;Download Files with FTP&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.IO;&lt;br /&gt;using System.Net;&lt;br /&gt;using System.Text;&lt;br /&gt;&lt;br /&gt;namespace Examples.System.Net&lt;br /&gt;{&lt;br /&gt;public class WebRequestGetExample&lt;br /&gt;{&lt;br /&gt;public static void Main ()&lt;br /&gt;{&lt;br /&gt;// Get the object used to communicate with the server.&lt;br /&gt;FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://www.contoso.com/test.htm");&lt;br /&gt;request.Method = WebRequestMethods.Ftp.DownloadFile;&lt;br /&gt;&lt;br /&gt;// This example assumes the FTP site uses anonymous logon.&lt;br /&gt;request.Credentials = new NetworkCredential ("anonymous","janeDoe@contoso.com");&lt;br /&gt;&lt;br /&gt;FtpWebResponse response = (FtpWebResponse)request.GetResponse();&lt;br /&gt;&lt;br /&gt;Stream responseStream = response.GetResponseStream();&lt;br /&gt;StreamReader reader = new StreamReader(responseStream);&lt;br /&gt;Console.WriteLine(reader.ReadToEnd());&lt;br /&gt;&lt;br /&gt;Console.WriteLine("Download Complete, status {0}", response.StatusDescription);&lt;br /&gt;&lt;br /&gt;reader.Close();&lt;br /&gt;response.Close();  &lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Upload :&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;namespace Examples.System.Net&lt;br /&gt;{&lt;br /&gt;public class WebRequestGetExample&lt;br /&gt;{&lt;br /&gt;public static void Main ()&lt;br /&gt;{&lt;br /&gt;// Get the object used to communicate with the server.&lt;br /&gt;FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://www.contoso.com/test.htm");&lt;br /&gt;request.Method = WebRequestMethods.Ftp.UploadFile;&lt;br /&gt;&lt;br /&gt;// This example assumes the FTP site uses anonymous logon.&lt;br /&gt;request.Credentials = new NetworkCredential ("anonymous","janeDoe@contoso.com");&lt;br /&gt;&lt;br /&gt;// Copy the contents of the file to the request stream.&lt;br /&gt;StreamReader sourceStream = new StreamReader("testfile.txt");&lt;br /&gt;byte [] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());&lt;br /&gt;sourceStream.Close();&lt;br /&gt;request.ContentLength = fileContents.Length;&lt;br /&gt;&lt;br /&gt;Stream requestStream = request.GetRequestStream();&lt;br /&gt;requestStream.Write(fileContents, 0, fileContents.Length);&lt;br /&gt;requestStream.Close();&lt;br /&gt;&lt;br /&gt;FtpWebResponse response = (FtpWebResponse)request.GetResponse();&lt;br /&gt;&lt;br /&gt;Console.WriteLine("Upload File Complete, status {0}", response.StatusDescription);&lt;br /&gt;&lt;br /&gt;response.Close();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;b&gt;List Directory Contents with FTP&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;namespace Examples.System.Net&lt;br /&gt;{&lt;br /&gt;    public class WebRequestGetExample&lt;br /&gt;    {&lt;br /&gt;        public static void Main ()&lt;br /&gt;        {&lt;br /&gt;            // Get the object used to communicate with the server.&lt;br /&gt;            FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://www.contoso.com/");&lt;br /&gt;            request.Method = WebRequestMethods.Ftp.ListDirectoryDetails;&lt;br /&gt;&lt;br /&gt;            // This example assumes the FTP site uses anonymous logon.&lt;br /&gt;            request.Credentials = new NetworkCredential ("anonymous","janeDoe@contoso.com");&lt;br /&gt;&lt;br /&gt;            FtpWebResponse response = (FtpWebResponse)request.GetResponse();&lt;br /&gt;    &lt;br /&gt;            Stream responseStream = response.GetResponseStream();&lt;br /&gt;            StreamReader reader = new StreamReader(responseStream);&lt;br /&gt;            Console.WriteLine(reader.ReadToEnd());&lt;br /&gt;&lt;br /&gt;            Console.WriteLine("Directory List Complete, status {0}", response.StatusDescription);&lt;br /&gt;    &lt;br /&gt;            reader.Close();&lt;br /&gt;            response.Close();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-1774155525575835830?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/1774155525575835830/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2011/10/upload-download-files-with-ftp.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/1774155525575835830'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/1774155525575835830'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2011/10/upload-download-files-with-ftp.html' title='Upload &amp; Download Files with FTP'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-5046303580461327710</id><published>2011-10-21T12:50:00.000-07:00</published><updated>2011-10-21T12:51:51.885-07:00</updated><title type='text'>Dynamically Add checkBox to GridView</title><content type='html'>'Code to Create checkbox dynamically...  &lt;br /&gt;Private Sub ADDCheckBox_Column(ByVal gridName As DataGridView)&lt;br /&gt;Dim AddColumn As New DataGridViewCheckBoxColumn&lt;br /&gt;With AddColumn&lt;br /&gt;' .HeaderText = "CheckAll"&lt;br /&gt;.Name = "Check"&lt;br /&gt;.Width = 10&lt;br /&gt;End With&lt;br /&gt;gridName.Columns.Insert(0, AddColumn)&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;'Code for checkAll event...&lt;br /&gt;Private Sub chkCheckAll_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkCheckAll.CheckedChanged&lt;br /&gt;&lt;br /&gt;If chkCheckAll.Checked = True Then&lt;br /&gt;For i As Integer = 0 To dgvFacility.Rows.Count - 1&lt;br /&gt;dgvFacility(0, i).Value = True&lt;br /&gt;Next&lt;br /&gt;Else&lt;br /&gt;For i As Integer = 0 To dgvFacility.Rows.Count - 1&lt;br /&gt;dgvFacility(0, i).Value = False&lt;br /&gt;Next&lt;br /&gt;End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;'Code to get ids when user select checkBox from gridview&lt;br /&gt; For i As Integer = 0 To dgManagement.Rows.Count - 1&lt;br /&gt;            If TypeOf Me.dgManagement.Rows(i).Cells(0) Is DataGridViewCheckBoxCell Then&lt;br /&gt;                row = dgManagement.Rows(i)&lt;br /&gt;                If CBool((row.Cells(0)).FormattedValue) = True Then&lt;br /&gt;                    lst.Add(dgManagement.Rows(i).Cells(1).Value)&lt;br /&gt;                    lstrptName.Add(dgManagement.Rows(i).Cells(2).Value)&lt;br /&gt;                End If&lt;br /&gt;            End If&lt;br /&gt;Next&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-5046303580461327710?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/5046303580461327710/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2011/10/dynamically-add-checkbox-to-gridview.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/5046303580461327710'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/5046303580461327710'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2011/10/dynamically-add-checkbox-to-gridview.html' title='Dynamically Add checkBox to GridView'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-8330133848234321811</id><published>2011-08-01T06:43:00.001-07:00</published><updated>2011-11-06T21:19:52.642-08:00</updated><title type='text'>How To Create an ASP.NET HTTP Handler by Using Visual C# .NET</title><content type='html'>Implement the Handler&lt;br /&gt;1. Open Microsoft Visual Studio .NET. In Visual C# .NET, create a new Class Library project named MyHandler.&lt;br /&gt;2. Set a reference to the System.Web.dll assembly.&lt;br /&gt;3. Add the following directive to the class:&lt;br /&gt;4. using System.Web;&lt;br /&gt;&lt;br /&gt;5. Rename the class SyncHandler.cs, and then change the class definition to reflect this.&lt;br /&gt;6. Implement the IHttpHandler interface. Your class definition should appear as follows:&lt;br /&gt;7. public class SyncHandler : IHttpHandler&lt;br /&gt;&lt;br /&gt;8. Implement the IsReusable property and the ProcessRequest method of the IHttpHandler interface. Because this is a synchronous handler, return False for the IsReusable property so that the handler is not pooled.&lt;br /&gt;9. public bool IsReusable&lt;br /&gt;10. {&lt;br /&gt;11.    get {return false;}&lt;br /&gt;12. }&lt;br /&gt;13. &lt;br /&gt;14. public void ProcessRequest(HttpContext context)&lt;br /&gt;15. {&lt;br /&gt;16.    context.Response.Write("Hello from custom handler.");&lt;br /&gt;17. }&lt;br /&gt;&lt;br /&gt;18. Compile the project.&lt;br /&gt;Deploy the Handler&lt;br /&gt;1. Create a new directory named Handler under the C:\Inetpub\Wwwroot directory.&lt;br /&gt;2. Create a subdirectory named Bin in the newly created Handler directory. The resultant path is C:\Inetpub\Wwwroot\Handler\Bin.&lt;br /&gt;3. Copy MyHandler.dll from your project's Bin\Debug directory to the C:\Inetpub\Wwwroot\Handler\Bin directory.&lt;br /&gt;4. Follow these steps to mark the new Handler directory as a Web application:&lt;br /&gt;a. Open Internet Services Manager.&lt;br /&gt;b. Right-click the Handler directory and then click Properties.&lt;br /&gt;c. On the Directory tab, click Create.&lt;br /&gt;5. Follow these steps to create an application mapping for the handler. For this handler, create a mapping to the Aspnet_isapi.dll file for the *.sync extension. Whenever a .sync file is requested, the request is routed to ASP.NET, and ASP.NET executes the code in the handler.&lt;br /&gt;. Right-click on the Handler Web application, and then click Properties.&lt;br /&gt;a. On the Directory tab, click Configuration.&lt;br /&gt;b. Click Add to add a new mapping.&lt;br /&gt;c. In the Executable text box, type the following path: Microsoft Windows 2000: &lt;br /&gt;C:\WINNT\Microsoft.NET\Framework\&lt;version#&gt;\Aspnet_isapi.dll &lt;br /&gt;Microsoft Windows XP: &lt;br /&gt;C:\WINDOWS\Microsoft.NET\Framework\&lt;version#&gt;\Aspnet_isapi.dll &lt;br /&gt;d. In the Extension text box, type .sync.&lt;br /&gt;e. Make sure that the Check that file exists check box is cleared, and then click OK to close the Add/Edit Application Extension Mapping dialog box.&lt;br /&gt;f. Click OK to close the Application Configuration and the Handler Properties dialog boxes.&lt;br /&gt;6. Close Internet Services Manager.&lt;br /&gt;Configure the System&lt;br /&gt;1. In the C:\Inetpub\Wwwroot\Handler directory, create a new file named Web.config.&lt;br /&gt;2. Add the following code to Web.config: &lt;br /&gt;3. &amp;lt;configuration&amp;gt;&lt;br /&gt;4.    &amp;lt;system.web&amp;gt;&lt;br /&gt;5.       &amp;lt;httphandlers&amp;gt;&lt;br /&gt;6.          &amp;lt;add verb="*" path="*.sync" type="MyHandler.SyncHandler, MyHandler" /&amp;gt;&lt;br /&gt;7.       &amp;lt;/httpHandlers&amp;gt;&lt;br /&gt;8.    &amp;lt;/system.web&amp;gt;&lt;br /&gt;9. &amp;lt;/configuration&amp;gt;&lt;br /&gt;&lt;br /&gt;In the verb="*" attribute, we instruct the handler to process a request that uses any verb (for &lt;br /&gt;example, POST, HEAD, GET, and so on). If you want this handler to process only the POST request, change this to verb="POST".&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In the path="*.sync" attribute, we instruct the handler to process any incoming requests for files with the .sync extension.&lt;br /&gt;&lt;br /&gt;In the type="MyHandler.SyncHandler, MyHandler" attribute, we instruct the handler that processes the request to implement in the MyHandler.SyncHandler namespace, and this class resides in the MyHandler assembly.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Test the Module&lt;br /&gt;To test a handler, a page does not need to exist in the file system. For example, request the Default.sync file in the Handler Web application (http://&lt;computername&gt;/Handler/Default.sync). You should receive the following results: &lt;br /&gt;Hello from custom handler.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-8330133848234321811?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/8330133848234321811/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2011/08/how-to-create-aspnet-http-handler-by.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/8330133848234321811'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/8330133848234321811'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2011/08/how-to-create-aspnet-http-handler-by.html' title='How To Create an ASP.NET HTTP Handler by Using Visual C# .NET'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-5023071905127885070</id><published>2011-07-26T01:33:00.000-07:00</published><updated>2011-07-26T01:33:45.824-07:00</updated><title type='text'>Public Key Encryption (RSA Method) for Encryption and Decryption...</title><content type='html'>The RSA Public Key Encryption is useful method for Encryption and Decryption .&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Collections;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Data;&lt;br /&gt;using System.Diagnostics;&lt;br /&gt;using System.Security;&lt;br /&gt;using System.Security.Cryptography;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.IO;&lt;br /&gt;&lt;br /&gt;public class Tester&lt;br /&gt;{&lt;br /&gt;    public static void Main()&lt;br /&gt;    {&lt;br /&gt;        RSACryptoServiceProvider myRSAProvide = new RSACryptoServiceProvider();&lt;br /&gt;        string strCrypt = null;&lt;br /&gt;        byte[] bteCrypt = null;&lt;br /&gt;        byte[] bteResult = null;&lt;br /&gt;        try&lt;br /&gt;        {&lt;br /&gt;            strCrypt = "12345678";&lt;br /&gt;            bteCrypt = Encoding.ASCII.GetBytes(strCrypt);&lt;br /&gt;            bteResult = myRSAProvide.Encrypt(bteCrypt, false);&lt;br /&gt;            Console.WriteLine(Encoding.ASCII.GetString(bteResult));&lt;br /&gt;        }&lt;br /&gt;        catch (CryptographicException ex)&lt;br /&gt;        {&lt;br /&gt;            Console.WriteLine(ex.Message);&lt;br /&gt;        }&lt;br /&gt;        string strResault = null;&lt;br /&gt;        byte[] bteDecrypt = null;&lt;br /&gt;        try&lt;br /&gt;        {&lt;br /&gt;            bteDecrypt = myRSAProvide.Decrypt(bteResult, false);&lt;br /&gt;            strResault = Encoding.ASCII.GetString(bteDecrypt);&lt;br /&gt;            Console.WriteLine(strResault);&lt;br /&gt;        }&lt;br /&gt;        catch (CryptographicException ex)&lt;br /&gt;        {&lt;br /&gt;            Console.WriteLine(ex.Message);&lt;br /&gt;        }&lt;br /&gt;        Console.ReadLine();&lt;br /&gt;    }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-5023071905127885070?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/5023071905127885070/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2011/07/public-key-encryption-rsa-method-for.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/5023071905127885070'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/5023071905127885070'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2011/07/public-key-encryption-rsa-method-for.html' title='Public Key Encryption (RSA Method) for Encryption and Decryption...'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-6992343835616367685</id><published>2011-07-19T05:06:00.000-07:00</published><updated>2011-07-19T05:06:53.223-07:00</updated><title type='text'>How to implement impersonation in an ASP.NET application</title><content type='html'>&lt;b&gt;Impersonate the IIS Authenticated Account or User:&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;To impersonate the Microsoft Internet Information Services (IIS) authenticating user on every request for every page in an ASP.NET application, you must include an &lt;identity&gt; tag in the Web.config file of this application and set the impersonate attribute to true. For example: &lt;br /&gt;&lt;br /&gt;&amp;lt identity impersonate="true" / &amp;gt&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Impersonate a Specific User for All the Requests of an ASP.NET Application:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;To impersonate a specific user for all the requests on all pages of an ASP.NET application, you can specify the userName and password attributes in the &lt;identity&gt; tag of the Web.config file for that application. For example:&lt;br /&gt;&lt;br /&gt;&amp;lt identity impersonate="true" userName="accountname" password="password" / &amp;gt&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-6992343835616367685?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/6992343835616367685/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2011/07/how-to-implement-impersonation-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/6992343835616367685'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/6992343835616367685'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2011/07/how-to-implement-impersonation-in.html' title='How to implement impersonation in an ASP.NET application'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-4441846233956165911</id><published>2011-07-19T04:54:00.001-07:00</published><updated>2011-07-19T05:03:17.044-07:00</updated><title type='text'>Use the 'Globalization' section in web.config</title><content type='html'>If you're from Denmark (like me!) chances are you would like all dates, numbers etc. formatted "the danish way" on your website. Instead of writing custom code on every page, you should instead tell ASP.NET which CultureInfo, Encoding etc. to use.&lt;br /&gt;&lt;br /&gt;&amp;lt configuration &amp;gt&lt;br /&gt;&amp;lt system.web &amp;gt&lt;br /&gt;&amp;lt globalization&lt;br /&gt;       fileEncoding="utf-8"&lt;br /&gt;       requestEncoding="utf-8"&lt;br /&gt;       responseEncoding="utf-8"&lt;br /&gt;       culture="da-DK"&lt;br /&gt;       uiCulture="da-DK" / &amp;gt&lt;br /&gt;&amp;lt /system.web &amp;gt&lt;br /&gt;&amp;lt /configuration &amp;gt&lt;br /&gt;&lt;br /&gt;Values are valid if they are accepted by the related classes Encoding and CultureInfo. You can find more information about the Encoding and CultureInfo classes in the .NET Framework SDK.&lt;br /&gt;&lt;br /&gt;A call to the method "ToShortDateString()" on a DateTime instance will now result in dd-mm-yyyy or e.g. 26-11-2006, which is nice.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-4441846233956165911?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/4441846233956165911/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2011/07/use-globalization-section-in-webconfig.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/4441846233956165911'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/4441846233956165911'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2011/07/use-globalization-section-in-webconfig.html' title='Use the &apos;Globalization&apos; section in web.config'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-6368939910920937252</id><published>2011-07-04T21:17:00.000-07:00</published><updated>2011-07-04T21:17:01.196-07:00</updated><title type='text'>Introducing Linq</title><content type='html'>Linq is short for Language Integrated Query.&lt;br /&gt;&lt;br /&gt; Imagine we have a list of orders. For this example, we will imagine they are stored in memory, but they could be in a file on disk too. We want to get a list of the costs of all orders that were placed by the customer identified by the number 84. If we set about implementing this in C# before version 3 and a range of other popular languages, we would probably write something like (assuming C# syntax for familiarity): &lt;br /&gt;List&lt;double&gt; Found = new List&lt;double&gt;();&lt;br /&gt;foreach (Order o in Orders)&lt;br /&gt;    if (o.CustomerID == 84)&lt;br /&gt;        Found.Add(o.Cost);Here we are describing how to achieve the result we want by breaking the task into a series of instructions. This approach, which is very familiar to us, is called imperative programming. It relies on us to pick a good algorithm and not make any mistakes in the implementation of it; for more complex tasks, the algorithm is more complex and our chances of implementing it correctly decrease.&lt;br /&gt;&lt;br /&gt;If we had the orders stored in a table in a database and we used SQL to query it, we would write something like: &lt;br /&gt;SELECT Cost FROM Orders WHERE CustomerID = 84Here we have not specified an algorithm, or how to get the data. We have just declared what we want and left the computer to work out how to do it. This is known as declarative or logic programming.&lt;br /&gt;&lt;br /&gt;Linq brings declarative programming features into imperative languages. It is not language specific, and has been implemented in the Orcas version of VB.Net amongst other languages. In this series we are focusing on C# 3.0, but the principles will carry over to other languages.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Understanding A Simple Linq Query &lt;br /&gt;Let's jump straight into a code example. First, we'll create an Order class, then make a few instances of it in a List as our test data. With that done, we'll use Linq to get the costs of all orders for customer 84. &lt;br /&gt;class Order&lt;br /&gt;{&lt;br /&gt;    private int _OrderID;&lt;br /&gt;    private int _CustomerID;&lt;br /&gt;    private double _Cost;&lt;br /&gt;    public int OrderID&lt;br /&gt;    {&lt;br /&gt;        get { return _OrderID; }&lt;br /&gt;        set { _OrderID = value; }&lt;br /&gt;    }&lt;br /&gt;    public int CustomerID&lt;br /&gt;    {&lt;br /&gt;        get { return _CustomerID; }&lt;br /&gt;        set { _CustomerID = value; }&lt;br /&gt;    }&lt;br /&gt;    public double Cost&lt;br /&gt;    {&lt;br /&gt;        get { return _Cost; }&lt;br /&gt;        set { _Cost = value; }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;class Program&lt;br /&gt;{&lt;br /&gt;    static void Main(string[] args)&lt;br /&gt;    {&lt;br /&gt;        // Set up some test orders.&lt;br /&gt;        var Orders = new List&lt;Order&gt; {&lt;br /&gt;                         new Order {&lt;br /&gt;                             OrderID = 1,&lt;br /&gt;                             CustomerID = 84,&lt;br /&gt;                             Cost = 159.12&lt;br /&gt;                         },&lt;br /&gt;                         new Order {&lt;br /&gt;                             OrderID = 2,&lt;br /&gt;                             CustomerID = 7,&lt;br /&gt;                             Cost = 18.50&lt;br /&gt;                         },&lt;br /&gt;                         new Order {&lt;br /&gt;                             OrderID = 3,&lt;br /&gt;                             CustomerID = 84,&lt;br /&gt;                             Cost = 2.89&lt;br /&gt;                         }&lt;br /&gt;                     };&lt;br /&gt;        // Linq query.&lt;br /&gt;        var Found = from o in Orders&lt;br /&gt;                    where o.CustomerID == 84&lt;br /&gt;                    select o.Cost;&lt;br /&gt;        &lt;br /&gt;        // Display results.&lt;br /&gt;        foreach (var Result in Found)&lt;br /&gt;            Console.WriteLine("Cost: " + Result.ToString());&lt;br /&gt;    }&lt;br /&gt;}The output of running this program is: &lt;br /&gt;Cost: 159.12&lt;br /&gt;Cost: 2.89Let's walk through the Main method. First, we use collection and object initializers to create a list of Order objects that we can run our query over. Next comes the query - the new bit. We declare the variable Found and request that its type be inferred for us by using the "var" keyword.&lt;br /&gt;&lt;br /&gt;We then run across a new C# 3.0 keyword: "from". &lt;br /&gt;from o in OrdersThis is the keyword that always starts a query. You can read it a little bit like a "foreach": it takes a collection of some kind after the "in" keyword and makes what is to the left of the "in" keyword refer to a single element of the collection. Unlike "foreach", we do not have to write a type.&lt;br /&gt;&lt;br /&gt;Following this is another new keyword: "where". &lt;br /&gt;where o.CustomerID == 84This introduces a filter, allowing us to pick only some of the objects from the Orders collection. The "from" made the identifier "o" refer to a single item from the collection, and we write the condition in terms of this. If you type this query into the IDE yourself, you will notice that it has worked out that "o" is an Order and intellisense works as expected.&lt;br /&gt;&lt;br /&gt;The final new keyword is "select". &lt;br /&gt;select o.CostThis comes at the end of the query and is a little like a "return" statement: it states what we want to appear in the collection holding the results of the query. As well as primitive types (such as int), you can instantiate any object you like here. In this case, we will end up with Found being a List&lt;int&gt;, though.&lt;br /&gt;&lt;br /&gt;You may be thinking at this point, "hey, this looks like SQL but kind of backwards and twisted about a bit". That is a pretty good summary. I suspect many who have written a lot of SQL will find the "select comes last" a little grating at first; the other important thing to remember is that all of the conditions are to be expressed in C# syntax, not SQL syntax. That means "==" for equality testing, rather than "=" in SQL. Thankfully, in most cases that mistake will lead to a compile time error anyway.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;A Few More Simple Queries &lt;br /&gt;We may wish our query to return not only the Cost, but also the OrderID for each result that it finds. To do this we take advantage of anonymous types. &lt;br /&gt;var Found = from o in Orders&lt;br /&gt;            where o.CustomerID == 84&lt;br /&gt;            select new { OrderID = o.OrderID, Cost = o.Cost };Here we have defined an anonymous type that holds an OrderID and a Cost. This is where we start to see the power and flexibility that they offer; without them we would need to write custom classes for every possible set of results we wanted. Remembering the projection syntax, we can shorten this to: &lt;br /&gt;var Found = from o in Orders&lt;br /&gt;            where o.CustomerID == 84&lt;br /&gt;            select new { o.OrderID, o.Cost };And obtain the same result. Note that you can perform whatever computation you wish inside the anonymous type initializer. For example, we may wish to return the Cost of the order with an additional sales tax of 10% added on to it. &lt;br /&gt;var Found = from o in Orders&lt;br /&gt;            where o.CustomerID == 84&lt;br /&gt;            select new {&lt;br /&gt;                       o.OrderID,&lt;br /&gt;                       o.Cost,&lt;br /&gt;                       CostWithTax = o.Cost * 1.1&lt;br /&gt;                   };Conditions can be more complex too, and are built up in the usual C# way, just as you would do in an "if" statement. Here we apply an extra condition that we only want to see orders valued over a hundred pounds. &lt;br /&gt;var Found = from o in Orders&lt;br /&gt;            where o.CustomerID == 84 &amp;&amp; o.Cost &gt; 100&lt;br /&gt;            select new {&lt;br /&gt;                       o.OrderID,&lt;br /&gt;                       o.Cost,&lt;br /&gt;                       CostWithTax = o.Cost * 1.1&lt;br /&gt;                   };&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Ordering &lt;br /&gt;It is possible to sort the results based upon a field or the result of a computation involving one or more fields. This is achieved by using the new "orderby" keyword. &lt;br /&gt;var Found = from o in Orders&lt;br /&gt;            where o.CustomerID == 84&lt;br /&gt;            orderby o.Cost ascending&lt;br /&gt;            select new { o.OrderID, o.Cost };After the "orderby" keyword, we write the expression that the objects will be sorted on. In this case, it is a single field. Notice this is different from SQL, where there are two words: "ORDER BY". I have added the keyword "ascending" at the end, though this is actually the default. The result is that we now get the orders in order of increasing cost, cheapest to most expensive. To get most expensive first, we would have used the "descending" keyword.&lt;br /&gt;&lt;br /&gt;While I said earlier that the ordering condition is based on fields in the objects involved in the query, it actually doesn't have to be. Here's a way to get the results in a random order. &lt;br /&gt;Random R = new Random();&lt;br /&gt;var Found = from o in Orders&lt;br /&gt;            where o.CustomerID == 84&lt;br /&gt;            orderby R.Next()&lt;br /&gt;            select new { OrderID = o.OrderID, Cost = o.Cost };&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Joins &lt;br /&gt;So far we have just had one type of objects to run our query over. However, real life is usually more complex than this. For this example, let's introduce another class named Customer. &lt;br /&gt;class Customer&lt;br /&gt;{&lt;br /&gt;    private int _CustomerID;&lt;br /&gt;    private string _Name;&lt;br /&gt;    private string _Email;&lt;br /&gt;    public int CustomerID&lt;br /&gt;    {&lt;br /&gt;        get { return _CustomerID; }&lt;br /&gt;        set { _CustomerID = value; }&lt;br /&gt;    }&lt;br /&gt;    public string Name&lt;br /&gt;    {&lt;br /&gt;        get { return _Name; }&lt;br /&gt;        set { _Name = value; }&lt;br /&gt;    }&lt;br /&gt;    public string Email&lt;br /&gt;    {&lt;br /&gt;        get { return _Email; }&lt;br /&gt;        set { _Email = value; }&lt;br /&gt;    }&lt;br /&gt;}In the Main method, we will also instantiate a handful of Customer objects and place them in a list. &lt;br /&gt;var Customers = new List&lt;Customer&gt; {&lt;br /&gt;                    new Customer {&lt;br /&gt;                        CustomerID = 7,&lt;br /&gt;                        Name = "Emma",&lt;br /&gt;                        Email = "emz0r@worreva.com"&lt;br /&gt;                    },&lt;br /&gt;                    new Customer {&lt;br /&gt;                        CustomerID = 84,&lt;br /&gt;                        Name = "Pedro",&lt;br /&gt;                        Email = "pedro@cerveza.es"&lt;br /&gt;                    },&lt;br /&gt;                    new Customer {&lt;br /&gt;                        CustomerID = 102,&lt;br /&gt;                        Name = "Vladimir",&lt;br /&gt;                        Email = "vladimir@pivo.ru"&lt;br /&gt;                    }&lt;br /&gt;                };We would like to produce a list featuring all orders, stating the ID and cost of the order along with the name of the customer. To do this we need to involve both the List of orders and the List of customers in our query. This is achieved using the "join" keyword. Let's replace our query and output code with the following. &lt;br /&gt;// Query.&lt;br /&gt;var Found = from o in Orders&lt;br /&gt;            join c in Customers on o.CustomerID equals c.CustomerID&lt;br /&gt;            select new { c.Name, o.OrderID, o.Cost };&lt;br /&gt;// Display results.&lt;br /&gt;foreach (var Result in Found)&lt;br /&gt;    Console.WriteLine(Result.Name + " spent " + &lt;br /&gt;        Result.Cost.ToString() + " in order " +&lt;br /&gt;        Result.OrderID.ToString());The output of running this program is: &lt;br /&gt;Pedro spent 159.12 in order 1&lt;br /&gt;Emma spent 18.5 in order 2&lt;br /&gt;Pedro spent 2.89 in order 3We use the "join" keyword to indicate that we want to refer to another collection in our query. We then once again use the "in" keyword to declare an identifier that will refer to a single item in the collection; in this case it has been named "c". Finally, we need to specify how the two collections are related. This is achieved using the "on ... equals ..." syntax, where we name a field from each of the collections. In this case, we have stated that the CustomerID of an Order maps to the CustomerID of a Customer.&lt;br /&gt;&lt;br /&gt;When the query is evaluated, an object in the Customers collection is located to match each object in the Orders collection. Note that if there were many customers with the same ID, there may be more than one matching Customer object per Order object. In this case, we get extra results. For example, change Vladimir to also have an OrderID of 84. The output of the program would then be: &lt;br /&gt;Pedro spent 159.12 in order 1&lt;br /&gt;Vladimir spent 159.12 in order 1&lt;br /&gt;Emma spent 18.5 in order 2&lt;br /&gt;Pedro spent 2.89 in order 3&lt;br /&gt;Vladimir spent 2.89 in order 3Notice that Vladimir never featured in the results before, since he had not ordered anything.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Getting All Permutations With Multiple "from"s &lt;br /&gt;It is possible to write a query that gets every combination of the objects from two collections. This is achieved by using the "from" keyword multiple times. &lt;br /&gt;var Found = from o in Orders&lt;br /&gt;            from c in Customers&lt;br /&gt;            select new { c.Name, o.OrderID, o.Cost };Earlier I suggested that you could think of "from" as being a little bit like a "foreach". You can also think of multiple uses of "from" a bit like nested "foreach" loops; we are going to get every possible combination of the objects from the two collections. Therefore, the output will be: &lt;br /&gt;Emma spent 159.12 in order 1&lt;br /&gt;Pedro spent 159.12 in order 1&lt;br /&gt;Vladimir spent 159.12 in order 1&lt;br /&gt;Emma spent 18.5 in order 2&lt;br /&gt;Pedro spent 18.5 in order 2&lt;br /&gt;Vladimir spent 18.5 in order 2&lt;br /&gt;Emma spent 2.89 in order 3&lt;br /&gt;Pedro spent 2.89 in order 3&lt;br /&gt;Vladimir spent 2.89 in order 3Which is not especially useful. You may have spotted that you could have used "where" in conjunction with the two "from"s to get the same result as the join: &lt;br /&gt;var Found = from o in Orders&lt;br /&gt;            from c in Customers&lt;br /&gt;            where o.CustomerID == c.CustomerID&lt;br /&gt;            select new { c.Name, o.OrderID, o.Cost };However, don't do this, since it computes all of the possible combinations before the "where" clause, which goes on to throw most of them away. This is a waste of memory and computation. A join, on the other hand, never produces them in the first place.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Grouping &lt;br /&gt;Another operations that you may wish to perform is categorizing objects that have the same value in a given field. For example, we might want to categorize orders by CustomerID. The result we expect back is a list of groups, where each group has a key (in this case, the CustomerID) and a list of matching objects. Here's the code to do the query and output the results. &lt;br /&gt;// Group orders by customer.&lt;br /&gt;var OrdersByCustomer = from o in Orders&lt;br /&gt;                       group o by o.CustomerID;&lt;br /&gt;// Iterate over the groups.&lt;br /&gt;foreach (var Cust in OrdersByCustomer)&lt;br /&gt;{&lt;br /&gt;    // About the customer...&lt;br /&gt;    Console.WriteLine("Customer with ID " + Cust.Key.ToString() +&lt;br /&gt;        " ordered " + Cust.Count().ToString() + " items.");&lt;br /&gt;    // And what they ordered.&lt;br /&gt;    foreach (var Item in Cust)&lt;br /&gt;        Console.WriteLine("    ID: " + Item.OrderID.ToString() +&lt;br /&gt;            " Cost: " + Item.Cost.ToString());&lt;br /&gt;}The output that it produces is as follows: &lt;br /&gt;Customer with ID 84 ordered 2 items.&lt;br /&gt;    ID: 1 Cost: 159.12&lt;br /&gt;    ID: 3 Cost: 2.89&lt;br /&gt;Customer with ID 7 ordered 1 items.&lt;br /&gt;    ID: 2 Cost: 18.5This query looks somewhat different to the others that we have seen so far in that it does not end with a "select". The first line is the same as we're used to. The second introduces the new "group" and "by" keywords. After the "by" we name the field that we are going to group the objects by. Before the "by" we put what we would like to see in the resulting per-group collections. In this case, we write "o" so as to get the entire object. If we had only been interested in the Cost field, however, we could have written: &lt;br /&gt;// Group orders by customer.&lt;br /&gt;var OrdersByCustomer = from o in Orders&lt;br /&gt;                       group o.Cost by o.CustomerID;&lt;br /&gt;// Iterate over the groups.&lt;br /&gt;foreach (var Cust in OrdersByCustomer)&lt;br /&gt;{&lt;br /&gt;    // About the customer...&lt;br /&gt;    Console.WriteLine("Customer with ID " + Cust.Key.ToString() +&lt;br /&gt;        " ordered " + Cust.Count().ToString() + " items.");&lt;br /&gt;    // And the costs of what they ordered.&lt;br /&gt;    foreach (var Cost in Cust)&lt;br /&gt;        Console.WriteLine("    Cost: " + Cost.ToString());&lt;br /&gt;}Which produces the output: &lt;br /&gt;Customer with ID 84 ordered 2 items.&lt;br /&gt;    Cost: 159.12&lt;br /&gt;    Cost: 2.89&lt;br /&gt;Customer with ID 7 ordered 1 items.&lt;br /&gt;    Cost: 18.5You are not restricted to just a single field or the object itself; you could, for example, instantiate an anonymous type there instead.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Query Continuations &lt;br /&gt;At this point you might be wondering if you can follow a "group ... by ..." with a "select". The answer is yes, but not directly. Both "group ... by ..." and "select" are special in so far as they produce a result. You must terminate a Linq query with one or the other. If you try to do something like: &lt;br /&gt;var CheapOrders = from o in Orders&lt;br /&gt;                  where o.Cost &lt; 10;Then it will lead to a compilation error. Since both "select" and "group ... by ..." terminate a query, you need a way of taking the results and using them as the input to another query. This is called a query continuation, and the keyword for this is "into".&lt;br /&gt;&lt;br /&gt;In the following example we take the result of grouping orders by customer and then use a select to return an anonymous type containing the CustomerID and the number of orders that the customer has placed. &lt;br /&gt;var OrderCounts = from o in Orders&lt;br /&gt;                  group o by o.CustomerID into g&lt;br /&gt;                  select new {&lt;br /&gt;                             CustomerID = g.Key,&lt;br /&gt;                             TotalOrders = g.Count()&lt;br /&gt;                         };Notice the identifier "g", which we introduce after the keyword "into". This identifier represents an item in the collection containing the results of the previous query. We use in the select statement. Remember that each element of the collection we are querying in this second query is actually a collection itself, since this is what "group ... by ..." produces. Therefore, we can call Count() on it to get the number of elements, which is the number of orders per customer. We grouped by the CustomerID field, so that is our Key.&lt;br /&gt;&lt;br /&gt;Query continuations can be used to chain together as many selection and grouping queries as you need in whatever order you need.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-6368939910920937252?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/6368939910920937252/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2011/07/introducing-linq.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/6368939910920937252'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/6368939910920937252'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2011/07/introducing-linq.html' title='Introducing Linq'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-5252124042759638650</id><published>2011-07-04T21:12:00.001-07:00</published><updated>2011-07-04T21:12:41.650-07:00</updated><title type='text'>SQL Server Performance Check List</title><content type='html'>SQl Server Performance :&lt;br /&gt;&lt;br /&gt;CheckList:&lt;br /&gt;&lt;br /&gt;1. Schema&lt;br /&gt;&lt;br /&gt;Define all primary keys and foreign key relationships.&lt;br /&gt;Define all unique constraints and check constraints.&lt;br /&gt;Choose the most appropriate data type.&lt;br /&gt;Partition tables vertically and horizontally.&lt;br /&gt;&lt;br /&gt;2. Queries:&lt;br /&gt;&lt;br /&gt;Write correctly formed queries.&lt;br /&gt;Return only the rows and columns needed.&lt;br /&gt;Avoid expensive operators such as NOT LIKE.&lt;br /&gt;Avoid explicit or implicit functions in WHERE clauses.&lt;br /&gt;Use stored procedures or parameterized queries.&lt;br /&gt;Minimize cursor use.&lt;br /&gt;Limit query and index hint use&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;3. Indexes:&lt;br /&gt;&lt;br /&gt;Create indexes based on use.&lt;br /&gt;Keep clustered index keys as small as possible.&lt;br /&gt;Create an index on all foreign keys.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;4. Stored Procedures&lt;br /&gt;&lt;br /&gt;Use Set NOCOUNT ON in stored procedures. &lt;br /&gt;Do not use the sp_prefix for custom stored procedures.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-5252124042759638650?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/5252124042759638650/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2011/07/sql-server-performance-check-list.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/5252124042759638650'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/5252124042759638650'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2011/07/sql-server-performance-check-list.html' title='SQL Server Performance Check List'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-8701213818726450086</id><published>2011-07-03T08:46:00.000-07:00</published><updated>2011-07-03T09:01:34.583-07:00</updated><title type='text'>Zoom Images Using JavaScript</title><content type='html'>Here on MouseOver it will increases the Height &amp; Width for the image, ViceVersa for ImageDecreasing.&lt;br /&gt;&lt;br /&gt;--&lt;br /&gt;&amp;lt; script language='javascript' ;&amp;gt&lt;br /&gt;&lt;br /&gt;function zoomIncrease()&lt;br /&gt;{&lt;br /&gt;document.getElementById('i1').style.height=300;&lt;br /&gt;document.getElementById('i1').style.width=550;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function zoomDecrease()&lt;br /&gt;{&lt;br /&gt;document.getElementById('i1').style.height=100;&lt;br /&gt;document.getElementById('i1').style.width=150;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&amp;lt; /script ;&amp;gt&lt;br /&gt;&lt;br /&gt;--Body&lt;br /&gt;&lt;br /&gt;&amp;lt; img src="D:\Sample.jpg" name="i1" height="100" width="150" onmouseout='zoomDecrease()' onmouseover='zoomIncrease();' ;&amp;gt &amp;lt;/img ;&amp;gt&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-8701213818726450086?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/8701213818726450086/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2011/07/zoom-images-using-javascript.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/8701213818726450086'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/8701213818726450086'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2011/07/zoom-images-using-javascript.html' title='Zoom Images Using JavaScript'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-7635338225940864183</id><published>2011-06-25T05:06:00.000-07:00</published><updated>2011-06-25T05:06:28.206-07:00</updated><title type='text'>Hash Algorithm Example</title><content type='html'>This topics just describes how to convert the data in into Hash Format &amp; How we can compare two Hash Values together,&lt;br /&gt;&lt;br /&gt;In the following exaple i have taken two TextBoxes &amp; Two button&lt;br /&gt;From First TextBox i will accept the value to be hashed &amp; then i will it to hash format and finally display into second text field.&lt;br /&gt;&lt;br /&gt;Declaring Variables:&lt;br /&gt;&lt;br /&gt; string txt;&lt;br /&gt; byte [] hashValue;&lt;br /&gt; byte [] messageKey;&lt;br /&gt; UnicodeEncoding uniCode;&lt;br /&gt; &lt;br /&gt;&lt;b&gt;Code for ComputeHash Button:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;            txt = textBox1.Text;&lt;br /&gt;            uniCode = new UnicodeEncoding();&lt;br /&gt;            messageKey = uniCode.GetBytes(txt);&lt;br /&gt;            SHA1Managed sha1 = new SHA1Managed();&lt;br /&gt;            hashValue = sha1.ComputeHash(messageKey);&lt;br /&gt;&lt;br /&gt;            foreach (byte b in hashValue)&lt;br /&gt;            { &lt;br /&gt;                textBox2.Text=textBox2.Text + string.Format("{0:X2}",b); &lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Code for Comparing Two Hash Value&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;            string f, f1;&lt;br /&gt;            f = txtf.Text;&lt;br /&gt;            f1 = txts.Text;&lt;br /&gt;&lt;br /&gt;            if (string.Equals(f, f1))&lt;br /&gt;            {&lt;br /&gt;                MessageBox.Show("both are equal");&lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;                MessageBox.Show("both are Unequal");&lt;br /&gt;            }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-7635338225940864183?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/7635338225940864183/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2011/06/hash-algorithm-example.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/7635338225940864183'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/7635338225940864183'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2011/06/hash-algorithm-example.html' title='Hash Algorithm Example'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-4557708762541805929</id><published>2011-06-25T04:54:00.000-07:00</published><updated>2011-06-25T04:54:08.760-07:00</updated><title type='text'>String Format for Int [C#]</title><content type='html'>Integer numbers can be formatted in .NET in many ways. You can use static method String.Format or instance method int.ToString. Following examples shows how to align numbers (with spaces or zeroes), how to format negative numbers or how to do custom formatting like phone numbers.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Add zeroes before number&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;To add zeroes before a number, use colon separator „:“ and write as many zeroes as you want.&lt;br /&gt;&lt;br /&gt;String.Format("{0:00000}", 15);          // "00015"&lt;br /&gt;String.Format("{0:00000}", -15);         // "-00015"&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;Align number to the right or left&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;To align number to the right, use comma „,“ followed by a number of characters. This alignment option must be before the colon separator.&lt;br /&gt;&lt;br /&gt;String.Format("{0,5}", 15);              // "   15"&lt;br /&gt;String.Format("{0,-5}", 15);             // "15   "&lt;br /&gt;String.Format("{0,5:000}", 15);          // "  015"&lt;br /&gt;String.Format("{0,-5:000}", 15);         // "015  "&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Different formatting for negative numbers and zero&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;You can have special format for negative numbers and zero. Use semicolon separator „;“ to separate formatting to two or three sections. The second section is format for negative numbers, the third section is for zero.&lt;br /&gt;&lt;br /&gt;String.Format("{0:#;minus #}", 15);      // "15"&lt;br /&gt;String.Format("{0:#;minus #}", -15);     // "minus 15"&lt;br /&gt;String.Format("{0:#;minus #;zero}", 0);  // "zero"&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Custom number formatting (e.g. phone number)&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Numbers can be formatted also to any custom format, e.g. like phone numbers or serial numbers.&lt;br /&gt;&lt;br /&gt;String.Format("{0:+### ### ### ###}", 447900123456); // "+447 900 123 456"&lt;br /&gt;String.Format("{0:##-####-####}", 8958712551);       // "89-5871-2551"&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-4557708762541805929?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/4557708762541805929/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2011/06/string-format-for-int-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/4557708762541805929'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/4557708762541805929'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2011/06/string-format-for-int-c.html' title='String Format for Int [C#]'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-1387184813474606901</id><published>2011-06-20T10:51:00.000-07:00</published><updated>2011-06-20T10:51:13.756-07:00</updated><title type='text'>Dropdown list bind with database inside gridview</title><content type='html'>protected void grid_RowCreated(object sender, GridViewRowEventArgs e)&lt;br /&gt;{&lt;br /&gt;     DropDownList drdList;&lt;br /&gt;     drdList = (DropDownList)e.Row.FindControl("drp");&lt;br /&gt;     if (drdList != null)&lt;br /&gt;     {&lt;br /&gt;                drdList.DataSource = ds.Tables[0];&lt;br /&gt;                drdList.DataMember = "ename";&lt;br /&gt;                drdList.DataValueField = "ename";&lt;br /&gt;                //drdList.DataTextField = "ename";&lt;br /&gt;                drdList.DataBind();&lt;br /&gt;&lt;br /&gt;     }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-1387184813474606901?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/1387184813474606901/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2011/06/dropdown-list-bind-with-database-inside.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/1387184813474606901'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/1387184813474606901'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2011/06/dropdown-list-bind-with-database-inside.html' title='Dropdown list bind with database inside gridview'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-5801720473177490614</id><published>2011-06-19T07:54:00.000-07:00</published><updated>2011-06-19T07:56:13.675-07:00</updated><title type='text'>Differences between varchar and nvarchar in SQL Server</title><content type='html'>VARCHAR is an abbreviation for variable-length character string. It's a string of text characters that can be as large as the page size for the database table holding the column in question. The size for a table page is 8,196 bytes, and no one row in a table can be more than 8,060 characters. This in turn limits the maximum size of a VARCHAR to 8,000 bytes.&lt;br /&gt;&lt;br /&gt;The "N" in NVARCHAR means uNicode. Essentially, NVARCHAR is nothing more than a VARCHAR that supports two-byte characters. The most common use for this sort of thing is to store character data that is a mixture of English and non-English symbols.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-5801720473177490614?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/5801720473177490614/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2011/06/differences-between-varchar-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/5801720473177490614'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/5801720473177490614'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2011/06/differences-between-varchar-and.html' title='Differences between varchar and nvarchar in SQL Server'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-8510889512755601393</id><published>2010-10-31T23:33:00.000-07:00</published><updated>2010-10-31T23:33:03.077-07:00</updated><title type='text'>String Format for DateTime [C#]</title><content type='html'>This example shows how to format DateTime using String.Format method. All formatting can be done also using DateTime.ToString method.&lt;br /&gt;&lt;br /&gt;Custom DateTime Formatting&lt;br /&gt;There are following custom format specifiers y (year), M (month), d (day), h (hour 12), H (hour 24), m (minute), s (second), f (second fraction), F (second fraction, trailing zeroes are trimmed), t (P.M or A.M) and z (time zone).&lt;br /&gt;&lt;br /&gt;Following examples demonstrate how are the format specifiers rewritten to the output.&lt;br /&gt;&lt;br /&gt;[C#]&lt;br /&gt;// create date time 2008-03-09 16:05:07.123&lt;br /&gt;DateTime dt = new DateTime(2008, 3, 9, 16, 5, 7, 123);&lt;br /&gt;&lt;br /&gt;String.Format("{0:y yy yyy yyyy}", dt);  // "8 08 008 2008"   year&lt;br /&gt;String.Format("{0:M MM MMM MMMM}", dt);  // "3 03 Mar March"  month&lt;br /&gt;String.Format("{0:d dd ddd dddd}", dt);  // "9 09 Sun Sunday" day&lt;br /&gt;String.Format("{0:h hh H HH}",     dt);  // "4 04 16 16"      hour 12/24&lt;br /&gt;String.Format("{0:m mm}",          dt);  // "5 05"            minute&lt;br /&gt;String.Format("{0:s ss}",          dt);  // "7 07"            second&lt;br /&gt;String.Format("{0:f ff fff ffff}", dt);  // "1 12 123 1230"   sec.fraction&lt;br /&gt;String.Format("{0:F FF FFF FFFF}", dt);  // "1 12 123 123"    without zeroes&lt;br /&gt;String.Format("{0:t tt}",          dt);  // "P PM"            A.M. or P.M.&lt;br /&gt;String.Format("{0:z zz zzz}",      dt);  // "-6 -06 -06:00"   time zone&lt;br /&gt;&lt;br /&gt;You can use also date separator / (slash) and time sepatator : (colon). These characters will be rewritten to characters defined in the current DateTimeForma tInfo.DateSepa rator and DateTimeForma tInfo.TimeSepa rator.&lt;br /&gt;&lt;br /&gt;[C#]&lt;br /&gt;// date separator in german culture is "." (so "/" changes to ".")&lt;br /&gt;String.Format("{0:d/M/yyyy HH:mm:ss}", dt); // "9/3/2008 16:05:07" - english (en-US)&lt;br /&gt;String.Format("{0:d/M/yyyy HH:mm:ss}", dt); // "9.3.2008 16:05:07" - german (de-DE)&lt;br /&gt;&lt;br /&gt;Here are some examples of custom date and time formatting:&lt;br /&gt;&lt;br /&gt;[C#]&lt;br /&gt;// month/day numbers without/with leading zeroes&lt;br /&gt;String.Format("{0:M/d/yyyy}", dt);            // "3/9/2008"&lt;br /&gt;String.Format("{0:MM/dd/yyyy}", dt);          // "03/09/2008"&lt;br /&gt;&lt;br /&gt;// day/month names&lt;br /&gt;String.Format("{0:ddd, MMM d, yyyy}", dt);    // "Sun, Mar 9, 2008"&lt;br /&gt;String.Format("{0:dddd, MMMM d, yyyy}", dt);  // "Sunday, March 9, 2008"&lt;br /&gt;&lt;br /&gt;// two/four digit year&lt;br /&gt;String.Format("{0:MM/dd/yy}", dt);            // "03/09/08"&lt;br /&gt;String.Format("{0:MM/dd/yyyy}", dt);          // "03/09/2008"&lt;br /&gt;&lt;br /&gt;Standard DateTime Formatting&lt;br /&gt;In DateTimeForma tInfo there are defined standard patterns for the current culture. For example property ShortTimePattern is string that contains value h:mm tt for en-US culture and value HH:mm for de-DE culture.&lt;br /&gt;&lt;br /&gt;Following table shows patterns defined in DateTimeForma tInfo and their values for en-US culture. First column contains format specifiers for the String.Format method.&lt;br /&gt;&lt;br /&gt;Specifier DateTimeFormatInfo property Pattern value (for en-US culture)&lt;br /&gt;t ShortTimePattern h:mm tt&lt;br /&gt;d ShortDatePattern M/d/yyyy&lt;br /&gt;T LongTimePattern h:mm:ss tt&lt;br /&gt;D LongDatePattern dddd, MMMM dd, yyyy&lt;br /&gt;f (combination of D and t) dddd, MMMM dd, yyyy h:mm tt&lt;br /&gt;F FullDateTimePattern dddd, MMMM dd, yyyy h:mm:ss tt&lt;br /&gt;g (combination of d and t) M/d/yyyy h:mm tt&lt;br /&gt;G (combination of d and T) M/d/yyyy h:mm:ss tt&lt;br /&gt;m, M MonthDayPattern MMMM dd&lt;br /&gt;y, Y YearMonthPattern MMMM, yyyy&lt;br /&gt;r, R RFC1123Pattern ddd, dd MMM yyyy HH':'mm':'ss 'GMT' (*)&lt;br /&gt;s SortableDateTi mePattern yyyy'-'MM'-'dd'T'HH':'mm':'ss (*)&lt;br /&gt;u UniversalSorta bleDateTimePat tern yyyy'-'MM'-'dd HH':'mm':'ss'Z' (*)&lt;br /&gt;    (*) = culture independent&lt;br /&gt;Following examples show usage of standard format specifiers in String.Format method and the resulting output.&lt;br /&gt;&lt;br /&gt;[C#]&lt;br /&gt;String.Format("{0:t}", dt);  // "4:05 PM"                         ShortTime&lt;br /&gt;String.Format("{0:d}", dt);  // "3/9/2008"                        ShortDate&lt;br /&gt;String.Format("{0:T}", dt);  // "4:05:07 PM"                      LongTime&lt;br /&gt;String.Format("{0:D}", dt);  // "Sunday, March 09, 2008"          LongDate&lt;br /&gt;String.Format("{0:f}", dt);  // "Sunday, March 09, 2008 4:05 PM"  LongDate+ShortTime&lt;br /&gt;String.Format("{0:F}", dt);  // "Sunday, March 09, 2008 4:05:07 PM" FullDateTime&lt;br /&gt;String.Format("{0:g}", dt);  // "3/9/2008 4:05 PM"                ShortDate+ShortTime&lt;br /&gt;String.Format("{0:G}", dt);  // "3/9/2008 4:05:07 PM"             ShortDate+LongTime&lt;br /&gt;String.Format("{0:m}", dt);  // "March 09"                        MonthDay&lt;br /&gt;String.Format("{0:y}", dt);  // "March, 2008"                     YearMonth&lt;br /&gt;String.Format("{0:r}", dt);  // "Sun, 09 Mar 2008 16:05:07 GMT"   RFC1123&lt;br /&gt;String.Format("{0:s}", dt);  // "2008-03-09T16:05:07"             SortableDateTime&lt;br /&gt;String.Format("{0:u}", dt);  // "2008-03-09 16:05:07Z"            UniversalSortableDateTime&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-8510889512755601393?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/8510889512755601393/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2010/10/string-format-for-datetime-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/8510889512755601393'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/8510889512755601393'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2010/10/string-format-for-datetime-c.html' title='String Format for DateTime [C#]'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-8908481433380197931</id><published>2010-10-16T00:10:00.000-07:00</published><updated>2010-10-16T00:10:19.347-07:00</updated><title type='text'>Gateway Provider Implementations</title><content type='html'>&lt;b&gt;Authorize.NET:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Authorize.NET has become the most popular Gateway provider and having written implementation code for various gateways I can see why. Authorize.NET is easy to work with and doesn't require any external configuration. Even if you were to start from scratch building an interface you could probably do it in very short order. Authorize.NET uses plain HTTP POST operations against its gateway server.&lt;br /&gt; &lt;br /&gt;The ccAuthorizeNet class provides Credit Card processing against the Authorize.Net Gateway. It uses plain POST operations against the Web Server so other than providing URL and login information there are no further setup requirements.&lt;br /&gt; &lt;br /&gt;&lt;b&gt;What you need:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Authorize.NET Gateway URL&lt;br /&gt;Authorize.NET Merchant Login ID and Password&lt;br /&gt;Referring URL&lt;br /&gt;No further installation required - uses plain POST interface to server gateway&lt;br /&gt;Here is the ccAuthorizeNet implementation:&lt;br /&gt; &lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// This class provides Credit Card processing against&lt;br /&gt;/// the Authorize.Net Gateway.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;public class ccAuthorizeNet : ccProcessing&lt;br /&gt;{&lt;br /&gt; &lt;br /&gt;      public ccAuthorizeNet()&lt;br /&gt;      {&lt;br /&gt;            this.HttpLink  = "https://secure.authorize.net/gateway/transact.dll";&lt;br /&gt;      }&lt;br /&gt; &lt;br /&gt;      /// &lt;summary&gt;&lt;br /&gt;      /// Validates the actual card against Authorize.Net Gateway using the HTTP&lt;br /&gt;      /// interface.&lt;br /&gt;      /// &lt;seealso&gt;Class ccAuthorizeNet&lt;/seealso&gt;&lt;br /&gt;      /// &lt;/summary&gt;&lt;br /&gt;      /// &lt;param name=""&gt;&lt;/param&gt;      /// &lt;returns&gt;Boolean&lt;/returns&gt;&lt;br /&gt;      public override bool ValidateCard()&lt;br /&gt;      {&lt;br /&gt;            if (!base.ValidateCard() )&lt;br /&gt;                  return false;&lt;br /&gt; &lt;br /&gt;            if (this.Http == null)&lt;br /&gt;            {&lt;br /&gt;                  this.Http = new wwHttp();&lt;br /&gt;                  this.Http.Timeout = this.Timeout;&lt;br /&gt;            }&lt;br /&gt; &lt;br /&gt;            string CardNo = Regex.Replace(this.CreditCardNumber,@"[ -/._#]","");&lt;br /&gt; &lt;br /&gt;            this.Http.AddPostKey("x_version","3.1");&lt;br /&gt;            this.Http.AddPostKey("x_method","CC");&lt;br /&gt;            this.Http.AddPostKey("x_delim_data","True");&lt;br /&gt;            this.Http.AddPostKey("x_password",this.MerchantPassword);&lt;br /&gt;            this.Http.AddPostKey("x_login",this.MerchantId);&lt;br /&gt; &lt;br /&gt;            if (this.UseTestTransaction)&lt;br /&gt;                  this.Http.AddPostKey("x_test_request","True");&lt;br /&gt;           &lt;br /&gt; &lt;br /&gt;            if (this.OrderAmount &gt;= 0)&lt;br /&gt;            {&lt;br /&gt;                  if (this.ProcessType == ccProcessTypes.Sale)&lt;br /&gt;                        this.Http.AddPostKey("x_type","AUTH_CAPTURE");&lt;br /&gt;                  else if (this.ProcessType == ccProcessTypes.PreAuth)&lt;br /&gt;                        this.Http.AddPostKey("x_type","AUTH_ONLY");&lt;br /&gt;                  else if (this.ProcessType == ccProcessTypes.Credit )&lt;br /&gt;                        this.Http.AddPostKey("x_type","CREDIT");&lt;br /&gt; &lt;br /&gt;                  this.Http.AddPostKey("x_amount",this.OrderAmount.ToString(&lt;br /&gt;                                    CultureInfo.InvariantCulture.NumberFormat));&lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;                  this.Http.AddPostKey("x_type","CREDIT");&lt;br /&gt;                  this.Http.AddPostKey("x_amount",((int) (-1 * this.OrderAmount)).ToString(CultureInfo.InvariantCulture.NumberFormat));&lt;br /&gt;            }&lt;br /&gt; &lt;br /&gt;            if (this.TaxAmount &gt; 0.00M)&lt;br /&gt;                  this.Http.AddPostKey("x_tax",&lt;br /&gt;this.TaxAmount.ToString(CultureInfo.InvariantCulture.NumberFormat));&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;            this.Http.AddPostKey("x_card_num",CardNo);&lt;br /&gt;            this.Http.AddPostKey("x_exp_date",this.CreditCardExpirationMonth.ToString() + "-" +&lt;br /&gt;                                                this.CreditCardExpirationYear.ToString() );&lt;br /&gt; &lt;br /&gt;            if (this.SecurityCode.Trim() != "")&lt;br /&gt;                  this.Http.AddPostKey("x_card_code",this.SecurityCode.Trim());&lt;br /&gt; &lt;br /&gt;           &lt;br /&gt;            this.Http.AddPostKey("x_first_name",this.Firstname);&lt;br /&gt;            this.Http.AddPostKey("x_last_name",this.Lastname);&lt;br /&gt;            this.Http.AddPostKey("x_company",this.Company);&lt;br /&gt;            this.Http.AddPostKey("x_address",this.Address);&lt;br /&gt;            this.Http.AddPostKey("x_city",this.City);&lt;br /&gt;            this.Http.AddPostKey("x_state",this.State);&lt;br /&gt;            this.Http.AddPostKey("x_zip",this.Zip);&lt;br /&gt;            this.Http.AddPostKey("x_country",this.Country);&lt;br /&gt;           &lt;br /&gt;            if (this.Phone.Trim() != "")&lt;br /&gt;                  this.Http.AddPostKey("x_phone",this.Phone);&lt;br /&gt; &lt;br /&gt;            this.Http.AddPostKey("x_email",this.Email);&lt;br /&gt; &lt;br /&gt;            this.Http.AddPostKey("x_invoice_num",this.OrderId);&lt;br /&gt;            this.Http.AddPostKey("x_description",this.Comment);&lt;br /&gt; &lt;br /&gt;            this.Http.CreateWebRequestObject(this.HttpLink);&lt;br /&gt;            this.Http.WebRequest.Referer=this.ReferringUrl;&lt;br /&gt; &lt;br /&gt;            this.RawProcessorResult = this.Http.GetUrl(this.HttpLink);&lt;br /&gt; &lt;br /&gt;            if (this.Http.Error)&lt;br /&gt;            {&lt;br /&gt;                  this.ValidatedResult = "FAILED";&lt;br /&gt;                  this.ValidatedMessage = this.Http.ErrorMessage;&lt;br /&gt;                  this.SetError(this.Http.ErrorMessage);&lt;br /&gt;                  this.LogTransaction();&lt;br /&gt;                  return false;&lt;br /&gt;            }&lt;br /&gt; &lt;br /&gt;            string[] Result = this.RawProcessorResult.Split(new char[1]  {','} );&lt;br /&gt;            if (Result == null)&lt;br /&gt;            {&lt;br /&gt;                  this.ValidatedResult = "FAILED";&lt;br /&gt;                  this.ValidatedMessage = "Invalid response received from Merchant Server";&lt;br /&gt;                  this.SetError(this.ValidatedMessage);&lt;br /&gt;                  this.LogTransaction();&lt;br /&gt;                  return false;&lt;br /&gt;            }&lt;br /&gt; &lt;br /&gt;            // *** REMEMBER: Result Codes are in 0 based array!&lt;br /&gt;      this.TransactionId = Result[6];&lt;br /&gt;            this.AvsResultCode = Result[5];&lt;br /&gt; &lt;br /&gt;            if (Result[0] == "3"  )  // Error - Processor communications usually&lt;br /&gt;            {&lt;br /&gt;            // *** Consider an invalid Card a DECLINE&lt;br /&gt;            // *** so we can send back to the customer for display&lt;br /&gt;            if (Result[3].IndexOf("credit card number is invalid") &gt; -1)&lt;br /&gt;                this.ValidatedResult = "DECLINED";&lt;br /&gt;            else&lt;br /&gt;                this.ValidatedResult = "FAILED";   &lt;br /&gt; &lt;br /&gt;                  this.ValidatedMessage = Result[3];&lt;br /&gt;                  this.SetError(this.ValidatedMessage);&lt;br /&gt;            }&lt;br /&gt;        if (Result[0] == "2" || Result[0] == "4")  // Declined&lt;br /&gt;        {&lt;br /&gt;            this.ValidatedResult = "DECLINED";&lt;br /&gt;            this.ValidatedMessage = Result[3];&lt;br /&gt;            if (this.ValidatedMessage == "")&lt;br /&gt;                this.ValidatedMessage = this.RawProcessorResult;&lt;br /&gt;            this.SetError(this.ValidatedMessage);&lt;br /&gt;        }&lt;br /&gt;        else&lt;br /&gt;        {&lt;br /&gt;            this.ValidatedResult = "APPROVED";&lt;br /&gt; &lt;br /&gt;            // *** Make the RawProcessorResult more readable for client application&lt;br /&gt;            this.ValidatedMessage = Result[3];&lt;br /&gt;            this.AuthorizationCode = Result[4];&lt;br /&gt;            this.SetError(null);&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;            this.LogTransaction();&lt;br /&gt; &lt;br /&gt;            return !this.Error;&lt;br /&gt;      }&lt;br /&gt;     &lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;Note, Authorize.NET's gateway API has become so popular that various smaller providers now offer Authorize.NET compatible gateways. For example, MerchantPlus offers its NaviGate gateway that uses the same Authorize.NET POST interface. Other smaller gateway providers are starting to do the same.&lt;br /&gt; &lt;br /&gt;The class above uses a custom wwHTTP class that's a thin wrapper around the .NET WebRequest class. It's provided as part of the sample downloads for this article.&lt;br /&gt;Verisign PayFlow Pro&lt;br /&gt;Verisign uses a custom API that is based  that is available in COM and .NET versions. The .NET version is merely a COM interop wrapper around the COM API, so it's a bit bulky to install as you have to register both the COM object and the interop assembly. In fact I found it easier to bypass the .NET API altogether and directly call the COM API to avoid the Interop assembly which really didn't provide any special features.&lt;br /&gt; &lt;br /&gt;The ccPayFlow class processes credit cards against Verisign PayFlowPro gateway service. This service is set up to work with the PayFlow Pro COM object which must be installed and configured properly on the machine to process credit cards. To avoid use of the Interop assembly, the class uses Late Binding with Reflection to invoke the COM API which is merely a single method call.&lt;br /&gt; &lt;br /&gt;To configure PayFlow Pro follow these steps: Download the PayFlow Pro SDK Version 3.0 from the Verisign Web Site. You can download a free trial from here: &lt;br /&gt;&lt;br /&gt; &lt;br /&gt;http://www.verisign.com/products/payflow/trial.html&lt;br /&gt;&lt;br /&gt;To install the SDK unzip the file into a directory. The following instructions are basic instructions for installing the PayFlow SDK itself - if you run into problems with this please check the SDK documentation.&lt;br /&gt;The implementation used with the Web Store uses the COM implementation of PayFlow so you will need to register the COM component. To do so:&lt;br /&gt;Find the Win32\Libs directory in the SDK&lt;br /&gt;Copy the pfPro.dll file into the Windows\System32 directory&lt;br /&gt;Find the Win32\COM in the SDK&lt;br /&gt;Run PFProCOMSetup.exe in the COM\ dir to install and register the Payflow Pro COM client&lt;br /&gt;Find and make a note of the Win32\Certs directory&lt;br /&gt;Create an Environment Variable called PFPRO_CERT_PATH and point it at this path&lt;br /&gt;To do this open Control Panel | System&lt;br /&gt;Go to the Advanced Tab&lt;br /&gt;Click on Environment Variables&lt;br /&gt;Select System Variables&lt;br /&gt;Create a new variable PFPRO_CERT_PATH&lt;br /&gt;Set the value to the path of the Cert directory&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;For ASP.Net operation the PFPRO_CERT_PATH environment variable is not available to the NETWORK SERVICE/ASPNET account by default and you have to manually copy the CERTS directory into the operating directory of the Web Server (or rather the IIS worker process). This directory is typically:&lt;br /&gt;&lt;Windows Path&gt;/System32/inetsrv&lt;br /&gt;&lt;br /&gt;Copy the SDK's entire Cert directory into this path so you have:&lt;br /&gt;&lt;br /&gt;&lt;Windows Path&gt;/System32/inetsrv/cert/&lt;br /&gt;&lt;br /&gt;with the content of the certificate file.&lt;br /&gt;&lt;br /&gt;If you've performed all these steps the PayFlow SDK should be up and running.&lt;br /&gt;&lt;br /&gt;In addition to the steps above you'll also need PayFlow UserId and Password which should be assigned to MerchantId and MerchantPassword respectively.&lt;br /&gt;&lt;br /&gt;Here's the implementation of the PayFlowPro class:&lt;br /&gt;&lt;br /&gt;public class ccPayFlowPro : ccProcessing&lt;br /&gt;{&lt;br /&gt;    public int HostPort&lt;br /&gt;    {&lt;br /&gt;        get { return _HostPort; }&lt;br /&gt;        set { _HostPort = value; }&lt;br /&gt;    }&lt;br /&gt;    private int _HostPort = 443;&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;    public string ProxyAddress&lt;br /&gt;    {&lt;br /&gt;        get { return _ProxyAddress; }&lt;br /&gt;        set { _ProxyAddress = value; }&lt;br /&gt;    }&lt;br /&gt;    private string _ProxyAddress = "";&lt;br /&gt; &lt;br /&gt;   &lt;br /&gt;    public int ProxyPort&lt;br /&gt;    {&lt;br /&gt;        get { return _ProxyPort; }&lt;br /&gt;        set { _ProxyPort = value; }&lt;br /&gt;    }&lt;br /&gt;    private int _ProxyPort = 0;&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;    public string ProxyUsername&lt;br /&gt;    {&lt;br /&gt;        get { return _ProxyUsername; }&lt;br /&gt;        set { _ProxyUsername = value; }&lt;br /&gt;    }&lt;br /&gt;    private string _ProxyUsername = "";&lt;br /&gt; &lt;br /&gt;    public string ProxyPassword&lt;br /&gt;    {&lt;br /&gt;        get { return _ProxyPassword; }&lt;br /&gt;        set { _ProxyPassword = value; }&lt;br /&gt;    }&lt;br /&gt;    private string _ProxyPassword = "";&lt;br /&gt; &lt;br /&gt;      /// &lt;summary&gt;&lt;br /&gt;      /// Sign up partner ID. Required only if you signed up through&lt;br /&gt;      /// a third party.&lt;br /&gt;      /// &lt;/summary&gt;&lt;br /&gt;    public string SignupPartner&lt;br /&gt;    {&lt;br /&gt;        get { return _SignupPartner; }&lt;br /&gt;        set { _SignupPartner = value; }&lt;br /&gt;    }&lt;br /&gt;    private string _SignupPartner = "Verisign";&lt;br /&gt; &lt;br /&gt;      /// &lt;summary&gt;&lt;br /&gt;      /// Overridden consistency with API names.&lt;br /&gt;    /// maps to MerchantId&lt;br /&gt;      /// &lt;/summary&gt;&lt;br /&gt;    public string UserId&lt;br /&gt;    {&lt;br /&gt;        get { return _UserId; }&lt;br /&gt;        set { _UserId = value; }&lt;br /&gt;    }&lt;br /&gt;    private string _UserId = "";&lt;br /&gt; &lt;br /&gt;    /// &lt;summary&gt;&lt;br /&gt;    /// Internal string value used to hold the values sent to the server&lt;br /&gt;    /// &lt;/summary&gt;&lt;br /&gt;    string Parameters = "";&lt;br /&gt; &lt;br /&gt;    /// &lt;summary&gt;&lt;br /&gt;      /// Validates the credit card. Supported transactions include only Sale or Credit.&lt;br /&gt;      /// Credits should have a negative sales amount.&lt;br /&gt;      /// &lt;/summary&gt;&lt;br /&gt;      /// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;      public override bool ValidateCard()&lt;br /&gt;      {&lt;br /&gt;            if (!base.ValidateCard())&lt;br /&gt;                  return false;&lt;br /&gt;           &lt;br /&gt;            this.Error = false;&lt;br /&gt;            this.ErrorMessage = "";&lt;br /&gt; &lt;br /&gt;            // *** Counter that holds our parameter string to send&lt;br /&gt;            this.Parameters = "";&lt;br /&gt; &lt;br /&gt;            // *** Sale and Credit Supported&lt;br /&gt;            decimal TOrderAmount = this.OrderAmount;&lt;br /&gt;            if (this.OrderAmount &lt; 0.00M)            {                  this.Parameters = "TRXTYPE=C";                  TOrderAmount = this.OrderAmount * -1.0M;            }            else                  this.Parameters = "TRXTYPE=S";             string CardNo = Regex.Replace(this.CreditCardNumber,@"[ -/._#]","");                       string TUserId = this.UserId;             if (TUserId == "")                  TUserId = this.MerchantId;             string ExpDate = string.Format("{0:##}",this.CreditCardExpirationMonth) ;            ExpDate +=  this.CreditCardExpirationYear;             this.Parameters += "&amp;TENDER=C" +                                "&amp;ACCT=" + CardNo +                                      "&amp;VENDOR=" + this.MerchantId +                                      "&amp;USER=" + TUserId +                                      "&amp;PWD=" + this.MerchantPassword +                                      "&amp;PARTNER=" + this.SignupPartner +                                      "&amp;AMT=" + TOrderAmount.ToString(CultureInfo.InvariantCulture.NumberFormat) +                                      "&amp;EXPDATE=" + ExpDate +                                      "&amp;STREET=" + this.Address +                                      "&amp;CITY=" + this.City +                                      "&amp;STATE=" + this.State +                                      "&amp;ZIP=" + this.Zip +                                      "&amp;EMAIL=" + this.Email +                                      "&amp;COMMENT1=" + this.Comment;                        if (this.TaxAmount &gt; 0.00M)&lt;br /&gt;            this.Parameters += "&amp;TAXAMT=" + this.TaxAmount.ToString(CultureInfo.InvariantCulture.NumberFormat);&lt;br /&gt; &lt;br /&gt;            if (this.SecurityCode != "")&lt;br /&gt;                  this.Parameters += "&amp;CVV2=" + this.SecurityCode;&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;        // ***  Save our raw input string for debugging&lt;br /&gt;        this.RawProcessorRequest = this.Parameters;&lt;br /&gt; &lt;br /&gt;            // *** connects to Verisign COM object to handle transaction&lt;br /&gt;            System.Type typPayFlow = System.Type.GetTypeFromProgID( "PFProCOMControl.PFProCOMControl.1" );&lt;br /&gt;            object PayFlow = Activator.CreateInstance( typPayFlow );&lt;br /&gt;           &lt;br /&gt;            this.RawProcessorResult = "";&lt;br /&gt; &lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;            // *** Use Reflection and Late binding to call COM object&lt;br /&gt;            // *** to avoid creating Interop assembly&lt;br /&gt;                  int context = (int) wwUtils.CallMethod(PayFlow,"CreateContext",this.HttpLink,this.HostPort,this.Timeout,&lt;br /&gt;                                                   this.ProxyAddress,this.ProxyPort,this.ProxyUsername, this.ProxyPassword);&lt;br /&gt;                 &lt;br /&gt;            this.RawProcessorResult = (string) wwUtils.CallMethod(PayFlow,"SubmitTransaction",context,Parameters,Parameters.Length);&lt;br /&gt; &lt;br /&gt;                  wwUtils.CallMethod(PayFlow, "DestroyContext",context);&lt;br /&gt;            }&lt;br /&gt;            catch(Exception ex)&lt;br /&gt;            {&lt;br /&gt;                  this.ValidatedResult = "FAILED";&lt;br /&gt;                  this.ValidatedMessage = ex.Message;&lt;br /&gt;                  this.LogTransaction();&lt;br /&gt;                  return false;&lt;br /&gt;            }&lt;br /&gt; &lt;br /&gt;            string ResultValue = wwHttpUtils.GetUrlEncodedKey(this.RawProcessorResult,"RESULT");&lt;br /&gt; &lt;br /&gt;        this.TransactionId = wwHttpUtils.GetUrlEncodedKey(this.RawProcessorResult, "PNREF");&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;            // *** 0 means success&lt;br /&gt;            if (ResultValue == "0")&lt;br /&gt;            {&lt;br /&gt;                  this.ValidatedResult = "APPROVED";&lt;br /&gt;            this.AuthorizationCode = wwHttpUtils.GetUrlEncodedKey(this.RawProcessorResult, "AUTHCODE");&lt;br /&gt;            this.LogTransaction();&lt;br /&gt;                  return true;&lt;br /&gt;            }&lt;br /&gt;                  // *** Empty response means we have an unknown failure&lt;br /&gt;            else if (ResultValue == "")&lt;br /&gt;            {&lt;br /&gt;                  this.ValidatedMessage = "Unknown Error";&lt;br /&gt;                  this.ValidatedResult = "FAILED";&lt;br /&gt;            }&lt;br /&gt;                  // *** Negative number means communication failure&lt;br /&gt;            else if (ResultValue.StartsWith("-") )&lt;br /&gt;            {&lt;br /&gt;                  this.ValidatedResult = "FAILED";&lt;br /&gt;                  this.ValidatedMessage = wwHttpUtils.GetUrlEncodedKey(this.RawProcessorResult,"RESPMSG");&lt;br /&gt;                 &lt;br /&gt;            }&lt;br /&gt;                  // *** POSITIVE number means we have a DECLINE&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;                 this.ValidatedResult = "DECLINED";&lt;br /&gt;             this.ValidatedMessage = wwHttpUtils.GetUrlEncodedKey(this.RawProcessorResult,"RESPMSG");&lt;br /&gt;            }&lt;br /&gt; &lt;br /&gt;            this.Error = true;&lt;br /&gt;            this.LogTransaction();&lt;br /&gt;            return false;&lt;br /&gt;      }&lt;br /&gt; &lt;br /&gt;}&lt;br /&gt;Note that this class implements a few additional provider specific properties such as the proxy settings and VerisignPartner.&lt;br /&gt;&lt;br /&gt;It's kind of ironic that this API uses COM to call out to the Verisign servers, but it requires a UrlEncoded input and output mechanism to get the actual result values.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-8908481433380197931?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/8908481433380197931/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2010/10/gateway-provider-implementations.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/8908481433380197931'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/8908481433380197931'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2010/10/gateway-provider-implementations.html' title='Gateway Provider Implementations'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-3386089354347502664</id><published>2010-10-13T12:00:00.000-07:00</published><updated>2010-10-13T12:00:48.394-07:00</updated><title type='text'>Create and Read Excel file from C#.Net</title><content type='html'>using Excel = Microsoft.Office.Interop.Excel; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt; private void releaseObject(object obj)       &lt;br /&gt; {&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);&lt;br /&gt;                obj = null;&lt;br /&gt;            }&lt;br /&gt;            catch (Exception ex)&lt;br /&gt;            {&lt;br /&gt;                obj = null;&lt;br /&gt;                MessageBox.Show("Exception Occured while releasing object " + ex.ToString());&lt;br /&gt;            }&lt;br /&gt;            finally&lt;br /&gt;            {&lt;br /&gt;                GC.Collect();&lt;br /&gt;            }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;Button Click Event:&lt;br /&gt;&lt;br /&gt; Excel.Application xlApp;&lt;br /&gt;            Excel.Workbook xlWorkBook;&lt;br /&gt;            Excel.Worksheet xlWorkSheet;&lt;br /&gt;            object misValue = System.Reflection.Missing.Value;&lt;br /&gt;&lt;br /&gt;            xlApp = new Excel.ApplicationClass();&lt;br /&gt;            xlWorkBook = xlApp.Workbooks.Add(misValue);&lt;br /&gt;&lt;br /&gt;            xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);&lt;br /&gt;            //xlWorkSheet.Cells[1, 1] = "http://csharp.net-informations.com";&lt;br /&gt;            xlWorkSheet.Cells[1, 1] = "Employee ID";&lt;br /&gt;            xlWorkSheet.Cells[1, 2] = "Employee Name";&lt;br /&gt;            xlWorkSheet.Cells[1, 3] = " Email";&lt;br /&gt;            xlWorkSheet.Cells[2, 1] = "100";&lt;br /&gt;            xlWorkSheet.Cells[2, 2] = "Vikas";&lt;br /&gt;            xlWorkSheet.Cells[2, 3] = "vikas@gmail.com";&lt;br /&gt;&lt;br /&gt;            xlWorkBook.SaveAs("csharp-Excel.xls", Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);&lt;br /&gt;            xlWorkBook.Close(true, misValue, misValue);&lt;br /&gt;            xlApp.Quit();&lt;br /&gt;&lt;br /&gt;            releaseObject(xlWorkSheet);&lt;br /&gt;            releaseObject(xlWorkBook);&lt;br /&gt;            releaseObject(xlApp);&lt;br /&gt;&lt;br /&gt;            MessageBox.Show("Excel file created , you can find the file c:\\csharp-Excel.xls");     &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//Read Excell File&lt;br /&gt;&lt;br /&gt; private void ReadExcell()&lt;br /&gt;        {&lt;br /&gt;            Excel.Application xlApp;&lt;br /&gt;            Excel.Workbook xlWorkBook;&lt;br /&gt;            Excel.Worksheet xlWorkSheet;&lt;br /&gt;            Excel.Range range;&lt;br /&gt;&lt;br /&gt;            string str;&lt;br /&gt;            int rCnt = 0;&lt;br /&gt;            int cCnt = 0;&lt;br /&gt;&lt;br /&gt;            xlApp = new Excel.ApplicationClass();&lt;br /&gt;            xlWorkBook = xlApp.Workbooks.Open("csharp-Excel.xls", 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);&lt;br /&gt;            xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);&lt;br /&gt;&lt;br /&gt;            range = xlWorkSheet.UsedRange;&lt;br /&gt;            ArrayList lst = new  ArrayList();&lt;br /&gt;&lt;br /&gt;            for (rCnt = 1; rCnt &lt;= range.Rows.Count; rCnt++)&lt;br /&gt;            {&lt;br /&gt;                for (cCnt = 1; cCnt &lt;= range.Columns.Count; cCnt++)&lt;br /&gt;                {&lt;br /&gt;                    str = Convert.ToString((range.Cells[rCnt, cCnt] as Excel.Range).Value2);&lt;br /&gt;                    lst.Add(str);        &lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            textBox1.Text = lst[0].ToString();&lt;br /&gt;            textBox2.Text = lst[1].ToString();&lt;br /&gt;            textBox3.Text = lst[2].ToString();&lt;br /&gt;&lt;br /&gt;            xlWorkBook.Close(true, null, null);&lt;br /&gt;            xlApp.Quit();&lt;br /&gt;&lt;br /&gt;            releaseObject(xlWorkSheet);&lt;br /&gt;            releaseObject(xlWorkBook);&lt;br /&gt;            releaseObject(xlApp);&lt;br /&gt;        &lt;br /&gt;  }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-3386089354347502664?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/3386089354347502664/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2010/10/create-and-read-excel-file-from-cnet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/3386089354347502664'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/3386089354347502664'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2010/10/create-and-read-excel-file-from-cnet.html' title='Create and Read Excel file from C#.Net'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-6985417251115139177</id><published>2010-10-06T10:09:00.000-07:00</published><updated>2010-10-06T10:09:52.121-07:00</updated><title type='text'>Transfer data from One Form to another Form in C#.Net</title><content type='html'>The Constructor Approach&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;This could be the easiest method of all. A method is invoked whenever you instantiate an object. This method is called a constructor. Code a constructor for form2 class with one string parameter. In the constructor assign the text to the label's text property. Instantiate form2 class in form1's button click event handler using the constructor with one string parameter and pass the textbox's text to the constructor.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Follow the below steps.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Step 1: Code a constructor for form2 class as below&lt;br /&gt;&lt;br /&gt; public Form2(string strTextBox)&lt;br /&gt; {&lt;br /&gt;&lt;br /&gt;    InitializeComponent();&lt;br /&gt;&lt;br /&gt;    label1.Text=strTextBox;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; } &lt;br /&gt;&lt;br /&gt;Step 2: Instantiate form2 class in form1's button click event handler as below&lt;br /&gt;&lt;br /&gt; private void button1_Click(object sender, System.EventArgs e)&lt;br /&gt;&lt;br /&gt; {&lt;br /&gt;&lt;br /&gt;    Form2 frm=new Form2(textBox1.Text); &lt;br /&gt;&lt;br /&gt;    frm.Show();&lt;br /&gt;&lt;br /&gt; }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-6985417251115139177?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/6985417251115139177/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2010/10/transfer-data-from-one-form-to-another.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/6985417251115139177'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/6985417251115139177'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2010/10/transfer-data-from-one-form-to-another.html' title='Transfer data from One Form to another Form in C#.Net'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-4604814686189047266</id><published>2010-10-01T12:43:00.000-07:00</published><updated>2010-10-01T12:43:52.352-07:00</updated><title type='text'>Agile Software Development</title><content type='html'>&lt;b&gt;What is Agile Software Development?&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;In the late 1990’s several methodologies began to get increasing public attention. Each had a different combination of old ideas, new ideas, and transmuted old ideas. But they all emphasized close collaboration between the programmer team and business experts; face-to-face communication (as more efficient than written documentation); frequent delivery of new deployable business value; tight, self-organizing teams; and ways to craft the code and the team such that the inevitable requirements churn was not a crisis&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;The Agile Manifesto&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The Agile Manifesto was written in February of 2001, at a summit of seventeen independent-minded practitioners of several programming methodologies. The participants didn't agree about much, but they found consensus around four main values.  &lt;br /&gt;&lt;br /&gt;The Manifesto for Agile Software Development&lt;br /&gt;We are uncovering better ways of developing software by doing it and helping others do it. &lt;br /&gt;Through this work we have come to value:&lt;br /&gt;&lt;br /&gt;Individuals and interactions over processes and tools&lt;br /&gt;Working software over comprehensive documentation&lt;br /&gt;Customer collaboration over contract negotiation&lt;br /&gt;Responding to change over following a plan&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;The Twelve Principles of Agile Software&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;We follow these principles:&lt;br /&gt;&lt;br /&gt;Our highest priority is to satisfy the customer through early and continuous delivery of valuable software.&lt;br /&gt;&lt;br /&gt;Welcome changing requirements, even late in development. Agile processes harness change for the customer's competitive advantage.&lt;br /&gt;&lt;br /&gt;Deliver working software frequently, from a couple of weeks to a couple of months, with a preference to the shorter timescale.&lt;br /&gt;&lt;br /&gt;Business people and developers must work together daily throughout the project.&lt;br /&gt;Build projects around motivated individuals. Give them the environment and support they need, and trust them to get the job done.&lt;br /&gt;&lt;br /&gt;The most efficient and effective method of conveying information to and within a development team is face-to-face conversation.&lt;br /&gt;&lt;br /&gt;Working software is the primary measure of progress.&lt;br /&gt;&lt;br /&gt;Agile processes promote sustainable development. The sponsors, developers, and users should be able to maintain a constant pace indefinitely.&lt;br /&gt;&lt;br /&gt;Continuous attention to technical excellence and good design enhances agility.&lt;br /&gt;&lt;br /&gt;Simplicity--the art of maximizing the amount of work not done--is essential.&lt;br /&gt;&lt;br /&gt;The best architectures, requirements, and designs emerge from self-organizing teams.&lt;br /&gt;&lt;br /&gt;At regular intervals, the team reflects on how to become more effective, then tunes and adjusts its behavior accordingly.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-4604814686189047266?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/4604814686189047266/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2010/10/agile-software-development.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/4604814686189047266'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/4604814686189047266'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2010/10/agile-software-development.html' title='Agile Software Development'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-4330708178117806419</id><published>2010-10-01T12:36:00.000-07:00</published><updated>2010-10-01T12:36:50.934-07:00</updated><title type='text'>Waterfall Model</title><content type='html'>There are various software development approaches defined and designed which are used/employed during development process of software, these approaches are also referred as "Software Development Process Models". Each process model follows a particular life cycle in order to ensure success in process of software development.&lt;br /&gt;&lt;br /&gt;One such approach/process used in Software Development is "The Waterfall Model". Waterfall approach was first Process Model to be introduced and followed widely in Software Engineering to ensure success of the project. In "The Waterfall" approach, the whole process of software development is divided into separate process phases. The phases in Waterfall model are: Requirement Specifications phase, Software Design, Implementation and Testing &amp; Maintenance. All these phases are cascaded to each other so that second phase is started as and when defined set of goals are achieved for first phase and it is signed off, so the name "Waterfall Model". All the methods and processes undertaken in Waterfall Model are more visible.&lt;br /&gt;&lt;br /&gt;The stages of "The Waterfall Model" are:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Requirement Analysis &amp; Definition: &lt;br /&gt;&lt;/b&gt;&lt;br /&gt;All possible requirements of the system to be developed are captured in this phase. Requirements are set of functionalities and constraints that the end-user (who will be using the system) expects from the system. The requirements are gathered from the end-user by consultation, these requirements are analyzed for their validity and the possibility of incorporating the requirements in the system to be development is also studied. Finally, a Requirement Specification document is created which serves the purpose of guideline for the next phase of the model.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;System &amp; Software Design:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt; Before a starting for actual coding, it is highly important to understand what we are going to create and what it should look like? The requirement specifications from first phase are studied in this phase and system design is prepared. System Design helps in specifying hardware and system requirements and also helps in defining overall system architecture. The system design specifications serve as input for the next phase of the model.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Implementation &amp; Unit Testing: &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;On receiving system design documents, the work is divided in modules/units and actual coding is started. The system is first developed in small programs called units, which are integrated in the next phase. Each unit is developed and tested for its functionality; this is referred to as Unit Testing. Unit testing mainly verifies if the modules/units meet their specifications.&lt;br /&gt;&lt;br /&gt;Integration &amp; System Testing: As specified above, the system is first divided in units which are developed and tested for their functionalities. These units are integrated into a complete system during Integration phase and tested to check if all modules/units coordinate between each other and the system as a whole behaves as per the specifications. After successfully testing the software, it is delivered to the customer.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Operations &amp; Maintenance: &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;This phase of "The Waterfall Model" is virtually never ending phase (Very long). Generally, problems with the system developed (which are not found during the development life cycle) come up after its practical use starts, so the issues related to the system are solved after deployment of the system. Not all the problems come in picture directly but they arise time to time and needs to be solved; hence this process is referred as Maintenance.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;There are some disadvantages of the Waterfall Model.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;1) As it is very important to gather all possible requirements during the Requirement Gathering and Analysis phase in order to properly design the system, not all requirements are received at once, the requirements from customer goes on getting added to the list even after the end of "Requirement Gathering and Analysis" phase, this affects the system development process and its success in negative aspects.&lt;br /&gt;&lt;br /&gt;2) The problems with one phase are never solved completely during that phase and in fact many problems regarding a particular phase arise after the phase is signed off, this results in badly structured system as not all the problems (related to a phase) are solved during the same phase.&lt;br /&gt;&lt;br /&gt;3) The project is not partitioned in phases in flexible way.&lt;br /&gt;&lt;br /&gt;4) As the requirements of the customer goes on getting added to the list, not all the requirements are fulfilled, this results in development of almost unusable system. These requirements are then met in newer version of the system; this increases the cost of system development.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-4330708178117806419?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/4330708178117806419/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2010/10/waterfall-model.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/4330708178117806419'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/4330708178117806419'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2010/10/waterfall-model.html' title='Waterfall Model'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-3794016886056003298</id><published>2010-10-01T12:26:00.000-07:00</published><updated>2010-10-04T10:36:29.515-07:00</updated><title type='text'>Sending Email in .Net2.0</title><content type='html'>MailMessage msg = new MailMessage();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            msg.To.Add(textBox1.Text);&lt;br /&gt;&lt;br /&gt;            msg.From = new MailAddress(textBox2.Text);&lt;br /&gt;&lt;br /&gt;            msg.CC.Add(textBox3.Text);&lt;br /&gt;&lt;br /&gt;            msg.Bcc.Add(textBox4.Text);&lt;br /&gt;&lt;br /&gt;            msg.Subject = textBox5.Text;&lt;br /&gt;&lt;br /&gt;            msg.Body = textBox6.Text;&lt;br /&gt;&lt;br /&gt;            msg.Attachments.Add(new Attachment(textBox7.Text));&lt;br /&gt;&lt;br /&gt;            SmtpClient smtp = new SmtpClient();&lt;br /&gt;&lt;br /&gt;            smtp.Credentials = new System.Net.NetworkCredential(textBox2.Text, "Password");&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            smtp.Host = "smtp.gmail.com";&lt;br /&gt;&lt;br /&gt;            smtp.EnableSsl = true;&lt;br /&gt;&lt;br /&gt;            smtp.Port = 587;&lt;br /&gt;&lt;br /&gt;            //smtp.UseDefaultCredentials=true;&lt;br /&gt;           &lt;br /&gt;            smtp.Send(msg);&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-3794016886056003298?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/3794016886056003298/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2010/10/sending-email-in-net20.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/3794016886056003298'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/3794016886056003298'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2010/10/sending-email-in-net20.html' title='Sending Email in .Net2.0'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-3145343497654010491</id><published>2010-09-07T11:51:00.000-07:00</published><updated>2010-09-07T11:51:26.530-07:00</updated><title type='text'>Working with FileInfo and DirectoryInfo classes</title><content type='html'>This article will explain about the Files and directory information and its operations. I have attached the sample web applications for FileInfo and DirectoryInfo classes. Let us see about these two classes. &lt;br /&gt;&lt;br /&gt;Basics &lt;br /&gt;&lt;br /&gt;The System.IO is one of the significant names which are used to work with the files in .Net framework. The FileInfo class which gives all the information about a file and DirectoryInfo class which gives all the information about a directory. &lt;br /&gt;&lt;br /&gt;FileInfo class will be used to get the information about a file path, extension, create time, last access time, last write time and length,etc..,It has few methods like delete and exists.&lt;br /&gt; &lt;br /&gt;FileInfo &lt;br /&gt;&lt;br /&gt;The FileInfo class resides in the System.IO namespace. This is used to get the information about a file stored on the server.&lt;br /&gt; &lt;br /&gt;The properties of the FileInfo class which inherits from the FileSystemInfo class. &lt;br /&gt;&lt;br /&gt;S.No Property Description&lt;br /&gt;1 CreationTime This property returns the creation of the file date and time.&lt;br /&gt;2 CreationTimeUtc It returns the creation of the file in Universal time&lt;br /&gt;3 Directory It returns the parent directory name&lt;br /&gt;4 DirectoryInfo It returns the full directory path&lt;br /&gt;5 Exists It returns whether the file exists or not as Boolean result.&lt;br /&gt;6 Extension It returns the type of the file in the extension name&lt;br /&gt;7 FullName It returns the full name of the file from the root directory.&lt;br /&gt;8 IsReadOnly It returns the file is read only or not in the Boolean result.&lt;br /&gt;9 Name It returns the name of the file&lt;br /&gt;10 LastAccessTime It returns the date and time of the last access time&lt;br /&gt;11 LastAccessTimeUtc It returns the last accessing date and time in universal format.&lt;br /&gt;12 LastWriteTime It returns the last file saving date and time&lt;br /&gt;13 LastWriteTimeUtc It returns the last write in the universal format&lt;br /&gt;14 Length It returns the size of the file content in the bytes format.&lt;br /&gt;&lt;br /&gt;The methods of the FileInfo class.&lt;br /&gt; &lt;br /&gt;The FileInfo class helps to work with the files like reading the existing file content, creating a new file which as specified in the FileInfo path, add the content to the existing file, copy the file into another new file, delete the exiting created file, move the file one place into another place.&lt;br /&gt; &lt;br /&gt;CreateText: &lt;br /&gt;&lt;br /&gt;This method is used to create a new file. The content can be written into the newly created file. &lt;br /&gt;&lt;br /&gt;FileInfo oFileInfo = new FileInfo(@"e:\SampleFile.txt");&lt;br /&gt;StreamWriter oStreamWriter = oFileInfo.CreateText();&lt;br /&gt;oStreamWriter.WriteLine("-----------------------------------");&lt;br /&gt;oStreamWriter.WriteLine("Sample file creation");&lt;br /&gt;oStreamWriter.WriteLine("Senthilkumar");&lt;br /&gt;oStreamWriter.WriteLine("-----------------------------------");&lt;br /&gt;oStreamWriter.Close();&lt;br /&gt;&lt;br /&gt;In the above code example, I have created a new file and added some content to that file.&lt;br /&gt; &lt;br /&gt;OpenText:&lt;br /&gt; &lt;br /&gt;The OpenText method is used to read the content from the existing file. &lt;br /&gt;&lt;br /&gt;FileInfo oFileInfo = new FileInfo(@"e:\SampleFile.txt");&lt;br /&gt;StreamReader oStreamReader = oFileInfo.OpenText();&lt;br /&gt;Console.WriteLine(oStreamReader.ReadToEnd());&lt;br /&gt;oStreamReader.Close();&lt;br /&gt;&lt;br /&gt;In the above example, whatever the content available in the SampleFile.txt will be printed.&lt;br /&gt; &lt;br /&gt;Create:&lt;br /&gt; &lt;br /&gt;This method is used to create the new file. &lt;br /&gt;&lt;br /&gt;FileInfo oFileInfo = new FileInfo(@"c:\NewFile.dat");&lt;br /&gt;FileStream oFileStream = oFileInfo.Create();&lt;br /&gt;oFileStream.Close();&lt;br /&gt;&lt;br /&gt;The above sample code will be created a new file name called NewFile in the c root directory.&lt;br /&gt; &lt;br /&gt;Delete:&lt;br /&gt;&lt;br /&gt;This method is used to delete the existing file. &lt;br /&gt;&lt;br /&gt;FileInfo oFileInfo = new FileInfo(@"c:\NewFile.dat");&lt;br /&gt;If (oFileInfo.Exists)&lt;br /&gt;{&lt;br /&gt;    oFileInfo.Delete ();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;CopyTo and MoveTo &lt;br /&gt;&lt;br /&gt;The CopyTo method is used to copy the existing file into new file. &lt;br /&gt;&lt;br /&gt;The MoveTo method is used to move the file one place to another valid location. &lt;br /&gt;&lt;br /&gt;DirectoryInfo &lt;br /&gt;&lt;br /&gt;The DirectoryInfo class is used to get the information about a directory and some operations like delete, create new directory and sub directories. &lt;br /&gt;&lt;br /&gt;There are methods to get the available files and directories. &lt;br /&gt;&lt;br /&gt;Let us see the properties of the DirectoryInfo class &lt;br /&gt;&lt;br /&gt;S.No Property Description&lt;br /&gt;1 CreationTime This property returns the creation of the directory date and time.&lt;br /&gt;2 CreationTimeUtc It returns the creation of the file in Universal time&lt;br /&gt;3 Exists It returns whether the directory exists or not as Boolean result.&lt;br /&gt;4 Extension It returns the type of the file in the extension name&lt;br /&gt;5 FullName It returns the full name of the file from the root directory.&lt;br /&gt;6 Name It returns the name of the directory&lt;br /&gt;7 LastAccessTime It returns the date and time of the last access time&lt;br /&gt;8 LastAccessTimeUtc It returns the last accessing date and time in universal format.&lt;br /&gt;9 LastWriteTime It returns the last file saving date and time&lt;br /&gt;10 LastWriteTimeUtc It returns the last write in the universal format&lt;br /&gt;11 Root It returns the Root directory.&lt;br /&gt;12 Parent It returns the Parent directory of the current directory&lt;br /&gt;13 LastWriteTimeUtc It returns the last write in the universal format&lt;br /&gt;14 Length It returns the size of the file content in the bytes format.&lt;br /&gt;&lt;br /&gt;Let us see the some of the methods in the DirectoryInfo class. &lt;br /&gt;&lt;br /&gt;Create: &lt;br /&gt;&lt;br /&gt;This method is used to create a new directory. &lt;br /&gt;&lt;br /&gt;DirectoryInfo oDirInfo = new DirectoryInfo (@"c:\SampleDir");&lt;br /&gt;If(oDirInfo.Exists)&lt;br /&gt;{&lt;br /&gt;    Console.WriteLine("Directory already exists!");&lt;br /&gt;    Return;&lt;br /&gt;}&lt;br /&gt;oDirInfo.Create();&lt;br /&gt;Console.WriteLine("Directory created!!");&lt;br /&gt;&lt;br /&gt;The above code will create the new directory. &lt;br /&gt; &lt;br /&gt;Delete: &lt;br /&gt;&lt;br /&gt;The Delete method is used to delete the directory. &lt;br /&gt;&lt;br /&gt;DirectoryInfo oDirInfo = new DirectoryInfo (@"c:\SampleDir");&lt;br /&gt;if (oDirInfo.Exists)&lt;br /&gt;{&lt;br /&gt;    oDirInfo.Delete();&lt;br /&gt;    Console.WriteLine("Directory Deleted!");&lt;br /&gt;}&lt;br /&gt;Else&lt;br /&gt;{&lt;br /&gt;    Console.WriteLine("Directory doesnot exists!");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;GetFiles:&lt;br /&gt; &lt;br /&gt;The GetFiles method is used to get the files in the specified folder. &lt;br /&gt;&lt;br /&gt;DirectoryInfo oDirInfo = new DirectoryInfo(@"c:\Windows");&lt;br /&gt;if (oDirInfo.Exists)&lt;br /&gt;{&lt;br /&gt;    FileInfo[] Files = oDirInfo.GetFiles();&lt;br /&gt;    foreach (object FileName in Files)&lt;br /&gt;    {&lt;br /&gt;        Console.WriteLine(FileName.ToString());&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;GetDirectories:&lt;br /&gt; &lt;br /&gt;This method is used to get the sub directories in the given directory path. &lt;br /&gt;&lt;br /&gt;DirectoryInfo oDirInfo = new DirectoryInfo(@"c:\windows");&lt;br /&gt;if (oDirInfo.Exists)&lt;br /&gt;{&lt;br /&gt;    DirectoryInfo[] Dirs = oDirInfo.GetDirectories();&lt;br /&gt;    foreach (object DirNames in Dirs)&lt;br /&gt;    {&lt;br /&gt;        Console.WriteLine(DirNames.ToString());&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;Else&lt;br /&gt;{&lt;br /&gt;   Console.WriteLine("The given directory doesnot exists");&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-3145343497654010491?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/3145343497654010491/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2010/09/working-with-fileinfo-and-directoryinfo.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/3145343497654010491'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/3145343497654010491'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2010/09/working-with-fileinfo-and-directoryinfo.html' title='Working with FileInfo and DirectoryInfo classes'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-422848813956545194</id><published>2010-09-07T11:44:00.000-07:00</published><updated>2010-09-07T11:45:58.069-07:00</updated><title type='text'>Example of DataGrid in ASP.NET</title><content type='html'>From Here we can design our web form. We use a DataGrid on webForm. Here we set all the property as we have to perform the operation with in DataGrid. &lt;br /&gt;&lt;br /&gt;This is .cs code in DataGrid:&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using System.Configuration;&lt;br /&gt;using System.Collections;&lt;br /&gt;using System.Web;&lt;br /&gt;using System.Web.Security;&lt;br /&gt;using System.Web.UI;&lt;br /&gt;using System.Web.UI.WebControls;&lt;br /&gt;using System.Web.UI.WebControls.WebParts;&lt;br /&gt;using System.Web.UI.HtmlControls;&lt;br /&gt;using System.Data.SqlClient;&lt;br /&gt;&lt;br /&gt;public partial class sapnamalik_DataGrid : System.Web.UI.Page&lt;br /&gt;{&lt;br /&gt;SqlDataAdapter da;&lt;br /&gt;DataSet ds = new DataSet();&lt;br /&gt;SqlCommand cmd = new SqlCommand();&lt;br /&gt;SqlConnection con;&lt;br /&gt;protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;if (!Page.IsPostBack)&lt;br /&gt;{&lt;br /&gt;BindData();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;public void BindData()&lt;br /&gt;{&lt;br /&gt;con = new SqlConnection(ConfigurationManager.AppSettings["connect"]);&lt;br /&gt;cmd.CommandText = "Select * from Employee";&lt;br /&gt;cmd.Connection = con;&lt;br /&gt;da = new SqlDataAdapter(cmd);&lt;br /&gt;da.Fill(ds);&lt;br /&gt;con.Open();&lt;br /&gt;cmd.ExecuteNonQuery();&lt;br /&gt;Grid.DataSource = ds;&lt;br /&gt;Grid.DataBind();&lt;br /&gt;con.Close();&lt;br /&gt;}&lt;br /&gt;protected void Grid_PageIndexChanged(object source, DataGridPageChangedEventArgs e)&lt;br /&gt;{&lt;br /&gt;Grid.CurrentPageIndex = e.NewPageIndex;&lt;br /&gt;BindData();&lt;br /&gt;}&lt;br /&gt;protected void Grid_EditCommand(object source, DataGridCommandEventArgs e)&lt;br /&gt;{&lt;br /&gt;Grid.EditItemIndex = e.Item.ItemIndex;&lt;br /&gt;BindData();&lt;br /&gt;}&lt;br /&gt;protected void Grid_CancelCommand(object source, DataGridCommandEventArgs e)&lt;br /&gt;{&lt;br /&gt;Grid.EditItemIndex = -1;&lt;br /&gt;BindData();&lt;br /&gt;}&lt;br /&gt;protected void Grid_DeleteCommand(object source, DataGridCommandEventArgs e)&lt;br /&gt;{&lt;br /&gt;con = new SqlConnection(ConfigurationManager.AppSettings["connect"]);&lt;br /&gt;cmd.Connection = con;&lt;br /&gt;int EmpId = (int)Grid.DataKeys[(int)e.Item.ItemIndex];&lt;br /&gt;cmd.CommandText = "Delete from Employee where EmpId=" + EmpId;&lt;br /&gt;cmd.Connection.Open();&lt;br /&gt;cmd.ExecuteNonQuery();&lt;br /&gt;cmd.Connection.Close();&lt;br /&gt;Grid.EditItemIndex = -1;&lt;br /&gt;BindData();&lt;br /&gt;}&lt;br /&gt;protected void Grid_UpdateCommand(object source, DataGridCommandEventArgs e)&lt;br /&gt;{&lt;br /&gt;con = new SqlConnection(ConfigurationManager.AppSettings["connect"]);&lt;br /&gt;cmd.Parameters.Add("@EmpId", SqlDbType.Int).Value = ((TextBox)e.Item.Cells[0].Controls[0]).Text;&lt;br /&gt;cmd.Parameters.Add("@F_Name", SqlDbType.Char).Value = ((TextBox)e.Item.Cells[1].Controls[0]).Text;&lt;br /&gt;cmd.Parameters.Add("@L_Name", SqlDbType.Char).Value = ((TextBox)e.Item.Cells[2].Controls[0]).Text;&lt;br /&gt;cmd.Parameters.Add("@City", SqlDbType.Char).Value = ((TextBox)e.Item.Cells[3].Controls[0]).Text;&lt;br /&gt;cmd.Parameters.Add("@EmailId", SqlDbType.Char).Value = ((TextBox)e.Item.Cells[4].Controls[0]).Text;&lt;br /&gt;cmd.Parameters.Add("@EmpJoining", SqlDbType.DateTime).Value = DateTime.Now.ToString();&lt;br /&gt;cmd.CommandText = "Update Employee set F_Name=@F_Name,L_Name=@L_Name,City=@City,EmailId=@EmailId,EmpJoining=@EmpJoining where EmpId=@EmpId";&lt;br /&gt;cmd.Connection = con;&lt;br /&gt;cmd.Connection.Open();&lt;br /&gt;cmd.ExecuteNonQuery();&lt;br /&gt;cmd.Connection.Close();&lt;br /&gt;Grid.EditItemIndex = -1;&lt;br /&gt;BindData();&lt;br /&gt;}&lt;br /&gt;protected void btnsubmit_Click(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;SqlConnection con;&lt;br /&gt;con = new SqlConnection(ConfigurationManager.AppSettings["connect"]);&lt;br /&gt;con.Open();&lt;br /&gt;SqlCommand cmd;&lt;br /&gt;cmd = new SqlCommand("Insert into Employee (EmpId,F_Name,L_Name,City,EmailId,EmpJoining) values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + TextBox6.Text + "')", con);&lt;br /&gt;cmd.ExecuteNonQuery();&lt;br /&gt;con.Close();&lt;br /&gt;}&lt;br /&gt;protected void btnReset_Click(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;TextBox1.Text = "";&lt;br /&gt;TextBox2.Text = "";&lt;br /&gt;TextBox3.Text = "";&lt;br /&gt;TextBox4.Text = "";&lt;br /&gt;TextBox5.Text = "";&lt;br /&gt;TextBox6.Text = "";&lt;br /&gt;}&lt;br /&gt;protected void btnOk_Click(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;BindData1();&lt;br /&gt;}&lt;br /&gt;public void BindData1()&lt;br /&gt;{&lt;br /&gt;con = new SqlConnection(ConfigurationManager.AppSettings["connect"]);&lt;br /&gt;cmd.CommandText = "Select * from Employee";&lt;br /&gt;cmd.Connection = con;&lt;br /&gt;da = new SqlDataAdapter(cmd);&lt;br /&gt;da.Fill(ds);&lt;br /&gt;con.Open();&lt;br /&gt;cmd.ExecuteNonQuery();&lt;br /&gt;Grid1.DataSource = ds;&lt;br /&gt;Grid1.DataBind();&lt;br /&gt;con.Close();&lt;br /&gt;}&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-422848813956545194?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/422848813956545194/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2010/09/example-of-datagrid-in-aspnet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/422848813956545194'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/422848813956545194'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2010/09/example-of-datagrid-in-aspnet.html' title='Example of DataGrid in ASP.NET'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-3318453049687902009</id><published>2010-09-07T11:31:00.000-07:00</published><updated>2010-09-07T11:31:05.968-07:00</updated><title type='text'>How to prevent multiple instances of child form in MDI windows form application in .NET</title><content type='html'>For preventing multiple instances of child form we can use ShowDialog() method. But it will be problematic to user because if user wants to work with many windows at a time he can not because he need to close opened window if he opened it with ShowDialog() method.&lt;br /&gt;&lt;br /&gt;So lets implement some code that will open new window, if there is no child window opened before. And if its opened previously then application will just focus that window and will not create any new child windows.&lt;br /&gt;&lt;br /&gt;private void button1_Click(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt; bool IsOpen = false;&lt;br /&gt; foreach (Form f in Application.OpenForms)&lt;br /&gt;    {&lt;br /&gt; if (f.Text == "Form2")&lt;br /&gt;        {&lt;br /&gt;            IsOpen = true;&lt;br /&gt;            f.Focus();&lt;br /&gt; break;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt; if (IsOpen == false)&lt;br /&gt;    {&lt;br /&gt;        Form2 f2 = new Form2();&lt;br /&gt;        f2.MdiParent = this;&lt;br /&gt;        f2.Show();&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;Understanding the code&lt;br /&gt;&lt;br /&gt;Here we have declared one variable that is used as flag for the child window is already opened or not? This flag will store the status of child form :)&lt;br /&gt;&lt;br /&gt;Now we iterate through each opened form in our application and check if any form with Form2 is already opened or not. If it is found, then we set flag to true and focus() that already opened form and break the loop.&lt;br /&gt;&lt;br /&gt;Now we are checking status of flag. If application sees that flag is still false after iterating then it will create a new instance of that child window :)&lt;br /&gt;&lt;br /&gt;That's it you are done !&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-3318453049687902009?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/3318453049687902009/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2010/09/how-to-prevent-multiple-instances-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/3318453049687902009'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/3318453049687902009'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2010/09/how-to-prevent-multiple-instances-of.html' title='How to prevent multiple instances of child form in MDI windows form application in .NET'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-6321370629773761685</id><published>2010-06-14T23:57:00.000-07:00</published><updated>2010-06-14T23:57:03.343-07:00</updated><title type='text'>TRY...CATCH in SQL Server 2005</title><content type='html'>SQL Server 2005 offers a number of new features over its predecessor, including many features aimed at making working with databases more like writing .NET application code. For example, in SQL Server 2005, stored procedures, triggers, UDFs, and so on can be written using any .NET Framework programming language (such as Visual Basic or C#). Another feature, and the focus of this article, is SQL Server 2005's support for TRY...CATCH blocks. TRY...CATCH blocks are the standard approach to exception handling in modern programming languages, and involve:&lt;br /&gt;&lt;br /&gt;A TRY Block - the TRY block contains the instructions that might cause an exception&lt;br /&gt;A CATCH Block - if an exception occurs from one of the statements in the TRY block, control is branched to the CATCH block, where the exception can be handled, logged, and so on.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Checking @@ERROR - the Old Way of Handling Errors in T-SQL&lt;br /&gt;SQL Server provides an @@ERROR variable that indicates the status of the last completed SQL statement in a given batch. If a SQL statement is completed successfully, @@ERROR is assigned 0. If, however, an error occurs, @@ERROR is set to the number of the error message.&lt;br /&gt;&lt;br /&gt;To see how the @@ERROR variable can be used, imagine that we have a data-driven web application that maintains employee information. Let's assume that our database has Employees and EmployeePhoneNumbers tables, among others. These two tables share a one-to-many relationship; that is, each Employees record can have an arbitrary number of related records in the EmployeePhoneNumbers table. There might be one for their office phone, one for their pager, one for their cell phone, and so on. Imagine that our database includes a stored procedure, DeleteEmployee, which is comprised of two DELETE statements - one to delete the employee's related phone numbers from the system and one to delete the actual employee record:&lt;br /&gt;&lt;br /&gt;CREATE PROCEDURE DeleteEmployee ( @EmployeeID int )&lt;br /&gt;AS&lt;br /&gt;&lt;br /&gt;-- Delete the Employee's phone numbers&lt;br /&gt;DELETE FROM EmployeePhoneNumbers&lt;br /&gt;WHERE EmployeeID = @EmployeeID&lt;br /&gt;&lt;br /&gt;-- Delete the Employee record&lt;br /&gt;DELETE FROM Employees&lt;br /&gt;WHERE EmployeeID = @EmployeeID&lt;br /&gt;&lt;br /&gt;Since we want these two delete statements to be atomic and either both fail or both succeed, we need to wrap up these two statements into a transaction. By using a transaction, we can rollback the transaction in the face of an error and undo any changes made since the start of the exception. To accomplish this we might initially try to use the following syntax:&lt;br /&gt;&lt;br /&gt;CREATE PROCEDURE DeleteEmployee ( @EmployeeID int )&lt;br /&gt;AS&lt;br /&gt;&lt;br /&gt;BEGIN TRANSACTION    -- Start the transaction&lt;br /&gt;&lt;br /&gt;-- Delete the Employee's phone numbers&lt;br /&gt;DELETE FROM EmployeePhoneNumbers&lt;br /&gt;WHERE EmployeeID = @EmployeeID&lt;br /&gt;&lt;br /&gt;-- Delete the Employee record&lt;br /&gt;DELETE FROM Employees&lt;br /&gt;WHERE EmployeeID = @EmployeeID&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;-- See if there is an error&lt;br /&gt;IF @@ERROR &lt;&gt; 0&lt;br /&gt;  -- There's an error b/c @ERROR is not 0, rollback&lt;br /&gt;  ROLLBACK&lt;br /&gt;ELSE&lt;br /&gt;  COMMIT   -- Success!  Commit the transaction&lt;br /&gt;&lt;br /&gt;This stored procedure (it appears) starts a transaction, runs the two DELETE statements, and then checks to see if there was an error. If there was one, it rolls the transaction back, else it commits the transaction. I say "it appears" because this syntax, while legal, is semantically incorrect because the @@ERROR variable is set after every SQL statement. Therefore, if the first DELETE statement has an error the @@ERROR variable will be set to its error number. Then, the second DELETE will execute. If this second DELETE succeeds, @@ERROR will be set back to 0, in which case the transaction will be committed even though there was a problem with the first statement! Whoops!&lt;br /&gt;&lt;br /&gt;Instead, a check must be made after every SQL statement to see if there has been an error. If so, the transaction must be rolled back and the stored procedure exited. This can lead to bulky scripts as a stored procedure with, say, five statements will have five checks against the @@ERROR variable. And if you forget to cut and paste a check in for a particular statement you're opening yourself up to a potential problem.&lt;br /&gt;&lt;br /&gt;For more information on transactions and the @@ERROR syntax used for checking for errors and rolling back as needed, see Managing Transactions in SQL Server Stored Procedures.&lt;br /&gt;&lt;br /&gt;Handling Errors With SQL Server 2005's TRY...CATCH Blocks&lt;br /&gt;While SQL Server 2005 still supports the @@ERROR approach, a better alternative exists with its new TRY...CATCH blocks. As with programming languages like Visual Basic, C#, and Java, the SQL Server 2005 TRY...CATCH block executes a number of statements in the TRY block. If there are no errors in any of the statements, control proceeds to after the CATCH block. If, however, one of the statements causes an error, control branches immediately to the start of the CATCH block. Furthermore, like programming languages, nested TRY...CATCH blocks are allowed, meaning that you can have an entire TRY...CATCH block in the TRY or CATCH portions of an "outter" TRY...CATCH block.&lt;br /&gt;&lt;br /&gt;BEGIN TRY&lt;br /&gt;   Try Statement 1&lt;br /&gt;   Try Statement 2&lt;br /&gt;   ...&lt;br /&gt;   Try Statement M&lt;br /&gt;END TRY&lt;br /&gt;BEGIN CATCH&lt;br /&gt;   Catch Statement 1&lt;br /&gt;   Catch Statement 2&lt;br /&gt;   ...&lt;br /&gt;   Catch Statement N&lt;br /&gt;END CATCH&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;BEGIN TRY&lt;br /&gt;   -- This will generate an error, as ProductID is an IDENTITY column&lt;br /&gt;   -- Ergo, we can't specify a value for this column...&lt;br /&gt;   INSERT INTO Products(ProductID, ProductName)&lt;br /&gt;   VALUES(1, 'Test')&lt;br /&gt;END TRY&lt;br /&gt;BEGIN CATCH&lt;br /&gt;   SELECT 'There was an error! ' + ERROR_MESSAGE()&lt;br /&gt;END CATCH&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-6321370629773761685?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/6321370629773761685/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2010/06/trycatch-in-sql-server-2005.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/6321370629773761685'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/6321370629773761685'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2010/06/trycatch-in-sql-server-2005.html' title='TRY...CATCH in SQL Server 2005'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-7033763827217864438</id><published>2010-05-26T01:43:00.000-07:00</published><updated>2010-05-26T01:43:51.682-07:00</updated><title type='text'>Integrating Electronic Payment Processing into ASP.NET Web Applications</title><content type='html'>http://www.west-wind.com/presentations/aspnetecommerce/aspnetecommerce.asp&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-7033763827217864438?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/7033763827217864438/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2010/05/integrating-electronic-payment.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/7033763827217864438'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/7033763827217864438'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2010/05/integrating-electronic-payment.html' title='Integrating Electronic Payment Processing into ASP.NET Web Applications'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-3273332072932799055</id><published>2010-05-26T00:47:00.000-07:00</published><updated>2010-05-26T00:47:55.428-07:00</updated><title type='text'>Storing User Profiles</title><content type='html'>User Profiles - The profile feature in ASP.NET 2.0 allows you to define and store per-user settings to be used throughout your application. Settings can also be stored in an anonymous profile while users are not logged in, and then migrated to a logged-in user profile at a later time.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Web sites frequently need a convenient method to store user-specific data that is applicable site-wide. The Profile feature delivers an easy-to-use approach for defining user-specific data as well storing and retrieving this user data. &lt;br /&gt;&lt;br /&gt;A user's profile is a collection of properties that define information you want to store for your web site's users. The user's profile is defined using a simple XML syntax in a configuration file (machine.config and/or web.config). Within your page, you reference a user's profile information with the Profile property. ASP.NET reads the schema defined in configuration, and automatically generates a class that is accessible from the Profile property on a page. You access properties on the Profile just as you would access properties on any other class. &lt;br /&gt;&lt;br /&gt;Although the most common use of the Profile feature is storing data for authenticated users, the Profile feature also supports storing information for anonymous users. Storing profile information for anonymous users depends on the Anonymous Identification feature. The Profile and Anonymous Identification features work together to enable the use of the Profile property for anonymous users. The samples included in the QuickStart demonstrate using the Profile feature with both authenticated and unauthenticated users. &lt;br /&gt;&lt;br /&gt;Prior to the start of the page lifecycle, ASP.NET ensures that the Profile is available for use by the page. Similarly, at the end of the ASP.NET page lifecycle, ASP.NET automatically saves the Profile to the underlying data store(s). As with other features such as Membership and Role Manager, the Profile feature has been designed with a provider-based model. Providers abstract the physical data storage for a feature from the classes and business logic exposed by a feature. The Profile feature ships with a provider for Microsoft™ SQL Server. You can create your own custom providers and configure them to work either the Profile feature. Pages that use the Profile feature will continue to work unchanged with your custom providers.&lt;br /&gt;In addition to the Profile property, the Profile feature provides support for administration of profiles (both for authenticated users and anonymous users) with the ProfileManager. Common tasks that you perform with the ProfileManager include:&lt;br /&gt;&lt;br /&gt;Searching for statistical information about all profiles, profiles for authenticated users, and profiles for anonymous users&lt;br /&gt;Determine the number of profiles that have not been modified in a given period of time&lt;br /&gt;Deleting individual profiles as well as deleting multiple profiles based on a profile's last modification date&lt;br /&gt;Defining the Profile Schema&lt;br /&gt;&lt;br /&gt;The configuration file in the following sample defines a Profile using properties, as well as a property group. Properties are defined using &lt;add&gt; elements within a &lt;properties&gt; element. A property group is a convenient way of logically grouping multiple properties. You define a property group with a &lt;group&gt; element. In the sample schema, a property group called "AutomobilePreferences" groups together two additional properties. Note that &lt;group&gt; elements cannot be nested (that is: there is only one level of group nesting supported beneath the &lt;properties&gt; element). &lt;br /&gt;&lt;br /&gt;The sample schema demonstrates the flexibility you have in terms of defining data types for your profile properties. By default, properties are assumed to be of type System.String. However, you can define a profile property using any type that is resolvable by the ASP.NET application at runtime. The sample schema includes definitions for System.Collections.ArrayList as well as System.Drawing.Color. &lt;br /&gt;&lt;br /&gt;Note that the &lt;add&gt; element supports a variety of optional attributes beyond those shown in this sample. Normally, the Profile feature serializes properties using either type conversion to a string, or Xml serialization. However, not all types are serializable as strings or as Xml fragments. This is why the "PreferredBackgroundColor" property has a serializeAs attribute that explicitly indicates binary serialization. The "PricePoint" property has a defaultValue attribute that defines the default value for this property if one has not already been set. &lt;br /&gt;&lt;br /&gt;The "PreferredBackgroundColor" property also has an allowAnonymous attribute that is set to true. By default, profile properties are restricted to authenticated users. When the allowAnonymous attribute is set to true this indicates that the property can also be used to load and store information for anonymous users. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Anonymous Profiles&lt;br /&gt;&lt;br /&gt;The profile schema shown in the last sample allows both authenticated and anonymous users to store their preferred background color. On the sample page an anonymous user can choose from a selection of colors. When the page refreshes it will render using the selected color. Notice that if you shut down the browser, and then re-run the sample, the color selection is remembered. The reason for this is that the Anonymous Identification feature is enabled for all of the samples (by default, Anonymous Identification is disabled). The Anonymous Identification feature automatically generates a random identifier for an anonymous user and stores it in a cookie. On subsequent visits to a site, the identifier in the cookie is used as a surrogate "id" when retrieving profile information for an anonymous user. &lt;br /&gt;&lt;br /&gt;In the sample page, you get and set the background color using the syntax Profile.PreferredBackgroundColor. The coding style for using a Profile property is the same as accessing properties on any other class. In this sample, the page uses some common conversions available on the System.Drawing.Color structure to get and set Profile.PreferredBackgroundColor. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Authenticated Profiles&lt;br /&gt;&lt;br /&gt;In this sample, you log in as an authenticated user and set values for all of the profile properties. When you first run the sample you will be on a home page that is accessible to both anonymous and authenticated users. Note that the background color is set to the value you selected as an anonymous user in the previous sample. Click on the link that allows you to create a new user (this link is at the bottom of the login control). Enter a username and a password and then click the button to create a new user. After the new user is created, click on the button to continue to the page that displays the profile properties for the logged in user. &lt;br /&gt;&lt;br /&gt;When you first view the page with all of your profile properties, you will notice that the background color is set to the selection you made earlier as an anonymous user. The reason for this is covered in more detail in the next sample. For now, notice that you can set values for all of the profile properties. Also, notice that initially the automobile price point is set to the default value defined in the profile schema. &lt;br /&gt;&lt;br /&gt;After entering new values in the HTML form, press the "Update Preferences" button. When the page refreshes the property changes take immediate effect. Click on the logout link to remove the Forms Authentication cookie from your machine. Then close the browser. Now, if you re-run the sample you will be prompted to log in again. After entering your credentials and logging in, notice that the profile properties page correctly displays the information you entered earlier. If you click on the link that takes you back to the home page, you will see that the home page uses both the name and the background color that you selected for the logged in user. This demonstrates how profile properties can be used across secured and non-secure pages on a site. On the home page the background color and name are displayed using either the anonymous user's Profile (if you are not logged in yet), or the logged in user's Profile (once you choose to log in). &lt;br /&gt;&lt;br /&gt;As with the anonymous example, this sample demonstrates how the Profile syntax follows the property accessor syntax for VB.NET and C#. Notice that the syntax for accessing a property within a property group uses two levels of property accessors: Profile.AutomobilePreferences.PricePoint. The property group simply acts as an intermediate property. The code for manipulating Profile.AutomobilePreferences.CarModels demonstrates using an System.Collections.Arraylist as a Profile property. The string that is typed into the HTML form should be a comma-delimited set of names. The page code parses this into an System.Array of strings prior to adding the array values to the Profile.AutomobilePreferences.CarModels property. When retrieving the car models, Profile.AutomobilePreferences.CarModels is enumerated using standard for-each syntax. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Migrating Anonymous Profiles to Authenticated Profiles&lt;br /&gt;&lt;br /&gt;In earlier samples it was demonstrated that the background color for an anonymous user was carried over to the authenticated user. You can verify this by running the sample below. If you are already logged in, click the logout link at the bottom of the page. On the home page, select a different color from the dropdown in the upper left corner of the page. The home page will refresh itself and display using the selected background color. Also, the page will have text stating "Hello Anonymous User" because the name property on the Profile is only supported for authenticated users. Log in to the site using the login control on the home page. Notice that once you log in, the background color on the profile properties page reflects the selection that was made earlier as an anonymous user. &lt;br /&gt;&lt;br /&gt;On the profile properties page, click the link that takes you back to the home page. Notice that on the home page the name that is displayed is based on the value set for the Profile.Name property. Now that you are back on the home page as an authenticated user, select a different color from the dropdown and click the update button. The page refreshes and uses the updated background color. If you then click on the link that leads back to the profile properties page, you will see that the background color is retained. &lt;br /&gt;&lt;br /&gt;Once you are back on the profile properties page, click on the logout link. This will redirect you back to the home page. Notice that when you are redirected to the home page, your previous selections for background color are no longer in effect. The reason for this is twofold. First, once you are logged out, the site considers you to be an anonymous user - as a result any background color that was set on the authenticated user's Profile is not available. Secondly, any color selection that was previously made when you were an anonymous user is no longer available. The reason for this is that once an anonymous users logs in, the cookie containing the autogenerated anonymous identifier was removed from the browser. As a result, when you log in, and then log out, the site considers you to be a completely new anonymous user. This interaction between anonymous users and logged in users leads to the need for migrating data from anonymous profiles to authenticated profiles. &lt;br /&gt;&lt;br /&gt;The Profile feature exposes an event called the MigrateAnonymous event. You can subscribe to this event by placing an event handler in global.asax called Profile_MigrateAnonymous. This event fires whenever an anonymous identifier is available (either as a cookie or in the URL as a cookieless ticket), and the current user is authenticated. Within the event handler, you can load the Profile for the anonymous user by calling Profile.GetProfile and passing in the anonymous ID (the anonymous ID is one of the properties available off of the event arguments). Once you have a reference to the anonymous Profile, you can transfer property settings from the anonymous Profile to the authenticated Profile. The sample global.asax file demonstrates transferring the background color from the anonymous Profile to the authenticated Profile. The code also deletes the anonymous Profile data from the database. Lastly, the code calls a method in Anonymous Identification to clear the cookie that contains the anonymous identifier. Note that developers must explicitly choose to clear the anonymous identifier from the request - otherwise ASP.NET will not automatically clear the identifier. By the time the MigrateAnonymous event completes, ASP.NET will have issued an Http header to clear the anonymous identifier from the browser, and on subsequent page requests the event will no longer fire.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Reference:http://quickstarts.asp.net/QuickStartv20/aspnet/doc/profile/default.aspx&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-3273332072932799055?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/3273332072932799055/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2010/05/storing-user-profiles.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/3273332072932799055'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/3273332072932799055'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2010/05/storing-user-profiles.html' title='Storing User Profiles'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-1099341007843280123</id><published>2010-05-26T00:36:00.000-07:00</published><updated>2010-05-26T00:36:58.403-07:00</updated><title type='text'>Themes in Asp.net</title><content type='html'>Asp.net 2.0 came with a new feature called a theme. A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in a Web application, across an entire Web application, or across all Web applications on a server.&lt;br /&gt;&lt;br /&gt;Themes are made up of a set of elements: skins, cascading style sheets (CSS), images, and other resources. Skins provide the ability to apply server-side styling to a control on the server side.  By providing a SkinID for the skin, this skin can be applied to a control that matches the skin type and SkinID; otherwise, if the SkinID is left null, then the skin will be applied globally.  For instance, take a look at the example below:&lt;br /&gt;&lt;br /&gt;asp:Button SkinID="One" runat="server" BackColor="Blue"  &lt;br /&gt;&lt;br /&gt;This skin is applied to any button that has a SkinID of "One".  However, the following skin is applied to every button:&lt;br /&gt;&lt;br /&gt;asp:Button runat="server" BackColor="Yellow"  &lt;br /&gt;&lt;br /&gt;A button with a SkinID set will use that skin over the skin that's globally applied.  At a minimum, a theme will contain skins, but it's common to include CSS files. Themes are defined in special directories in your Web site or on your Web server.  You can apply Themes dynamically also, but the theme should be applied only in the page_Preinit event by assigning a value to the Page.Theme property.&lt;br /&gt;&lt;br /&gt;You can also can theme third-party controls by adding them into a .skin and adding (if required) their reference.&lt;br /&gt;&lt;br /&gt;Best practices&lt;br /&gt;&lt;br /&gt;When to use themes/skins&lt;br /&gt;&lt;br /&gt;foreground images cannot be controlled by CSS&lt;br /&gt;CSSClasses have to be applied by hand for a control to change it's look and feel.&lt;br /&gt;For advenced controls and collections&lt;br /&gt;Switch image files based on the current theme&lt;br /&gt;&lt;br /&gt;What belongs in a theme&lt;br /&gt;&lt;br /&gt;CSS file specific to ASP.NET controls&lt;br /&gt;Images used for the advanced controls or other foreground images&lt;br /&gt;&lt;br /&gt;What does not belong in a theme&lt;br /&gt;&lt;br /&gt;Shared CSS files/styles&lt;br /&gt;Print CSS files/styles&lt;br /&gt;Global images&lt;br /&gt;Any content that has nothing to do with the content affected by the theme/skin&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-1099341007843280123?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/1099341007843280123/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2010/05/themes-in-aspnet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/1099341007843280123'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/1099341007843280123'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2010/05/themes-in-aspnet.html' title='Themes in Asp.net'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-4341801213763250375</id><published>2010-05-26T00:30:00.001-07:00</published><updated>2010-05-26T00:41:40.617-07:00</updated><title type='text'>ASP.NET 2.0 Site Navigation Features</title><content type='html'>http://weblogs.asp.net/scottgu/archive/2005/11/20/431019.aspx&lt;br /&gt;&lt;br /&gt;http://quickstarts.asp.net/QuickStartv20/aspnet/doc/navigation/default.aspx&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-4341801213763250375?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/4341801213763250375/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2010/05/aspnet-20-site-navigation-features.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/4341801213763250375'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/4341801213763250375'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2010/05/aspnet-20-site-navigation-features.html' title='ASP.NET 2.0 Site Navigation Features'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-8898500517348565267</id><published>2010-05-26T00:03:00.000-07:00</published><updated>2010-05-26T00:17:40.705-07:00</updated><title type='text'>Expand or collapse all TreeNodes with JavaScript</title><content type='html'>We can expand and collapse all TreeNodes on the server side, but it needs a post back. To avoid this, we can use JavaScript.&lt;br /&gt;&lt;br /&gt;In the sample code below, the function “TreeviewExpandCollapseAll” is used to demonstrate how to expand or collapse a TreeView. The function takes two parameters, the first parameter “treeViewId” is the TreeView control’s ID, and the second parameter “expandAll” is used to determine whether or not to expand the TreeView control.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;--Head section starts &lt;br /&gt;&lt;br /&gt;        function TreeviewExpandCollapseAll(treeViewId, expandAll) {&lt;br /&gt;            var displayState = (expandAll == true ? "none" : "block");&lt;br /&gt;            var treeView = document.getElementById(treeViewId);&lt;br /&gt;            if (treeView) {&lt;br /&gt;                var treeLinks = treeView.getElementsByTagName("a");&lt;br /&gt;                var nodeCount = treeLinks.length;&lt;br /&gt; &lt;br /&gt;                for (i = 0; i &lt; nodeCount; i++) {                    if (treeLinks[i].firstChild.tagName) {                        if (treeLinks[i].firstChild.tagName.toLowerCase() == "img") {                            var currentToggleLink = treeLinks[i];                            var childContainer = GetParentByTagName("table", currentToggleLink).nextSibling;                            if (childContainer.style.display == displayState) {                                eval(currentToggleLink.href);                            }                        }                    }                }            }        }    function GetParentByTagName(parentTagName, childElementObj)    {       var parent = childElementObj.parentNode;            while (parent.tagName.toLowerCase() != parentTagName.toLowerCase())             {                parent = parent.parentNode;            }            return parent;    }   a href="javascript:TreeviewExpandCollapseAll('&lt;%=TreeViewDemo.ClientID%&gt;',true)"&gt;Expand All &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;a href="javascript:TreeviewExpandCollapseAll('&lt;%=TreeViewDemo.ClientID%&gt;', false)"&gt;&lt;br /&gt;Collapse All    &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- Form Section ends here&lt;br /&gt;-Body section  Ends here&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-8898500517348565267?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/8898500517348565267/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2010/05/expand-or-collapse-all-treenodes-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/8898500517348565267'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/8898500517348565267'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2010/05/expand-or-collapse-all-treenodes-with.html' title='Expand or collapse all TreeNodes with JavaScript'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-1867912932611201803</id><published>2010-04-29T03:48:00.000-07:00</published><updated>2010-04-29T03:50:21.145-07:00</updated><title type='text'>Application and User Settings in C#.Net</title><content type='html'>Settings have four properties: &lt;br /&gt;&lt;br /&gt;Name: The Name property of settings is the name that is used to access the value of the setting at run time. &lt;br /&gt;&lt;br /&gt;Type: The Type of the setting is the .NET Framework type that the setting represents. A setting can be of any type. For example, a setting that holds a user preference of color would be a System.Color type.&lt;br /&gt;&lt;br /&gt;Scope: The Scope property represents how a setting can be accessed at run time. There are two possible values for the Scope property: Application and User. These will be discussed more in this section.&lt;br /&gt;&lt;br /&gt;Value: The Value property represents the value returned when the setting is accessed. The value will be of the type represented by the Type property.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Reading Settings at Run Time:&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;string strCon = Properties.Settings.Default.con;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Saving User Settings at Run Time:&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Application-scope settings are read only, and can only be changed at design time or by altering the &lt;assemblyname&gt;.exe.config file in between application sessions. User-scope settings, however, can be written at run time, just as you would change any property value. The new value persists for the duration of the application session. You can persist changes to user settings between application sessions by calling the Settings.Save method. These settings are saved in the User.config file.&lt;br /&gt;&lt;br /&gt;To Write and Persist User Settings at Run Time&lt;br /&gt;&lt;br /&gt;Access the user setting and assign it a new value, as shown in the following example: &lt;br /&gt;&lt;br /&gt;Properties.Settings.Default.myColor = Color.AliceBlue;&lt;br /&gt;&lt;br /&gt;If you want to persist changes to user settings between application sessions, call the Save method, as shown in the following code: &lt;br /&gt;&lt;br /&gt;Properties.Settings.Default.Save();&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-1867912932611201803?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/1867912932611201803/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2010/04/application-and-user-settings.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/1867912932611201803'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/1867912932611201803'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2010/04/application-and-user-settings.html' title='Application and User Settings in C#.Net'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-2757755958091719344</id><published>2010-04-23T03:38:00.000-07:00</published><updated>2010-04-23T03:38:50.653-07:00</updated><title type='text'>Regular Expressions and C#, .NET</title><content type='html'>&lt;b&gt;What are regular expressions? &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Regular expressions are Patterns that can be used to match strings. You can call it a formula for matching strings that follow some pattern. Regular expression(s) can be considered as a Language, which is designed to manipulate text. You can then ask questions such as&lt;br /&gt;&lt;br /&gt;“Does the given string match the pattern?”, or &lt;br /&gt;“Does the given string contain characters that match a pattern?”. &lt;br /&gt;Regular Expressions may be used to find one or more occurrences of a pattern of characters within a string. You may choose to replace it with some other characters or perform some other tasks based on the results obtained. These patterns of characters can be simple or very complex. Regular Expressions generally comprises of two types of characters –&lt;br /&gt;&lt;br /&gt;1) Literal or Normal Characters such as “abcd123” &lt;br /&gt;2) Special Characters that have a special meaning such as “.” Or “$” or “^”&lt;br /&gt;&lt;br /&gt;Due to the special characters Regular Expressions form a very powerful means of manipulating strings and text.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;.NET support for Regular Expressions:&lt;br /&gt;.Net provides an extensive set of Regular expressions which you could use to create, modify or compare strings. They can be classified as follows –&lt;br /&gt;&lt;br /&gt;a) Character Escapes &lt;br /&gt;b) Substitutions &lt;br /&gt;c) Character Classes &lt;br /&gt;d) Regular Expression Options &lt;br /&gt;e) Atomic Zero-Width Assertions &lt;br /&gt;f) Quantifiers &lt;br /&gt;g) Grouping Constructs &lt;br /&gt;h) Backreference Constructs &lt;br /&gt;i) Alternation Constructs &lt;br /&gt;j) Miscellaneous Constructs&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;Matches any single character. An example of this is the regular expression s.t would match the strings sat, sit, but not sight.&lt;br /&gt;&lt;br /&gt;$&lt;br /&gt;Matches the end of a line. For instance, the regular expression reason$ would match the end of the string "He has a reason" but not the string "He has his reasons"&lt;br /&gt;&lt;br /&gt;^&lt;br /&gt;Matches the beginning of a line. For instance, the regular expression ^Where would match the beginning of the string "Where is my cap" but would not match "Do you know Where it is " .&lt;br /&gt;&lt;br /&gt;*&lt;br /&gt;Matches zero or more occurrences of the character immediately preceding. For example, the regular expression .* means match any number of any characters.&lt;br /&gt;&lt;br /&gt;This is a escape or quoting character. The character after this is treated as an ordinary character. For example, ^ is used to match the caret sign character (^) rather than the beginning of a line. Similarly, the expression . is used to match the “.” character .&lt;br /&gt; &lt;br /&gt;[ ] &lt;br /&gt;[c1-c2]&lt;br /&gt;[^c1-c2] &lt;br /&gt;Matches any one of the characters between the brackets. &lt;br /&gt;For example, the regular expression s[ia]t matches sat, sit, but not set.&lt;br /&gt;&lt;br /&gt;Ranges of characters can specified by using a hyphen. &lt;br /&gt;For example, the regular expression [0-9] means match any digit. Multiple ranges can be specified as well. The regular expression [A-Za-z] means match any upper or lower case letter.&lt;br /&gt;&lt;br /&gt;To match any character except those in the range, the complement range, use the caret as the first character after the opening bracket. &lt;br /&gt;For example, the expression [^123a-z] will match any characters except 1,2, 3, and lower case letters.&lt;br /&gt; &lt;br /&gt;&lt; &gt;&lt;br /&gt;&lt;br /&gt;Matches the beginning ( &lt; ) or end ( &gt;) or a word. For example, &lt; THE&lt; _fckxhtmljob="2" span &gt; matches on "the" in the string "for the older" but does not match "the" in "rather"&lt;br /&gt; &lt;br /&gt;( )&lt;br /&gt;&lt;br /&gt;Treat the expression between ( and ) as a group. Also, saves the characters matched by the expression into temporary holding areas. Up to nine pattern matches can be saved in a single regular expression. They can be referenced as 1 through 9.&lt;br /&gt;|&lt;br /&gt;&lt;br /&gt;Or two conditions together. For example (him|her) matches the line "it belongs to him" and matches the line "it belongs to her" but does not match the line "it belongs to them."&lt;br /&gt; &lt;br /&gt;+&lt;br /&gt;&lt;br /&gt;Matches one or more occurrences of the character or regular expression immediately preceding. For example, the regular expression 9+ matches 9, 99, 999.&lt;br /&gt; &lt;br /&gt;?&lt;br /&gt;&lt;br /&gt;Matches 0 or 1 occurrence of the character or regular expression immediately preceding.&lt;br /&gt; &lt;br /&gt;{i}&lt;br /&gt;{i,j}&lt;br /&gt;&lt;br /&gt;Match a specific number of instances or instances within a range of the preceding character. &lt;br /&gt;For example, the expression A[0-9]{3} will match "A" followed by exactly 3 digits. That is, it will match A123 but not A1234.&lt;br /&gt;&lt;br /&gt;The expression [0-9]{4,6} any sequence of 4, 5, or 6 digits&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Character Escapes :&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The escape character (a single backslash) signals to the regular expression parser that the character following the backslash is not an operator&lt;br /&gt;&lt;br /&gt;b&lt;br /&gt;Matches a backspace&lt;br /&gt;t&lt;br /&gt;Matches a tab&lt;br /&gt;r&lt;br /&gt;Matches a carriage return&lt;br /&gt;v&lt;br /&gt;Matches a vertical tab&lt;br /&gt;f&lt;br /&gt;Matches a form feed&lt;br /&gt;n&lt;br /&gt;Matches a new line&lt;br /&gt;e&lt;br /&gt;Matches an escape&lt;br /&gt;40&lt;br /&gt;Matches an ASCII character as octal (up to three digits);&lt;br /&gt;x20&lt;br /&gt;Matches an ASCII character using hexadecimal representation (exactly two digits).&lt;br /&gt;cC&lt;br /&gt;Matches an ASCII control character; for example, cC is control-C.&lt;br /&gt;u0020&lt;br /&gt;Matches a Unicode character using hexadecimal representation (exactly four digits).&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Explanation of Regular Expressions: &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Regular expressions are used to search specified in the source string. &lt;br /&gt;&lt;br /&gt;Examples: &lt;br /&gt;&lt;br /&gt;Pattern#1&lt;br /&gt;Regex objNotNaturalPattern=new Regex("[^0-9]");&lt;br /&gt;&lt;br /&gt;Pattern#2  &lt;br /&gt;Regex objNaturalPattern=new Regex("0*[1-9][0-9]*");  &lt;br /&gt;&lt;br /&gt;Pattern#1 will match for strings other than 0 to 9.^ symbol is used for Specifying not condition.[] brackets if we are to give range values such as 0 - 9 or a-z or A-Z  &lt;br /&gt;&lt;br /&gt;eg. abc will return true &lt;br /&gt;&lt;br /&gt;123 will return false.    &lt;br /&gt;&lt;br /&gt;Pattern#2 will match for string which are Natural Numbers.Natural numbers Are numbers which are always greater than 0.The pattern 0* tells that a natural Number can be prefixed with any number of zero's or no zero's.the next [1-9] tells that it should contain atleast one number from 1 to 9 followed by any numbers of &lt;br /&gt;&lt;br /&gt;0-9's  &lt;br /&gt;&lt;br /&gt;Eg. 0007 returns true whereas 00 will return false.  &lt;br /&gt;&lt;br /&gt;Basic things to be understood in RegEx:  &lt;br /&gt;&lt;br /&gt;"*" matches 0 or more patterns&lt;br /&gt;"?" matches single character&lt;br /&gt;"^" for ignoring matches.&lt;br /&gt;"[]" for searching range patterns. &lt;br /&gt;&lt;br /&gt;More RegEx patterns in Next Article.  &lt;br /&gt;&lt;br /&gt;Source Code: &lt;br /&gt;&lt;br /&gt;// Source Code starts&lt;br /&gt;using System.Text.RegularExpressions;&lt;br /&gt;using System;&lt;br /&gt;/*&lt;br /&gt;&lt;HowToCompile&gt;&lt;br /&gt;csc /r:System.Text.RegularExpressions.dll,System.dll Validation.cs &lt;br /&gt;&lt;/HowToComplie&gt;&lt;br /&gt;*/ &lt;br /&gt;class Validation&lt;br /&gt;{ &lt;br /&gt;public static void Main()&lt;br /&gt;{&lt;br /&gt;String strToTest;&lt;br /&gt;Validation objValidate=new Validation();&lt;br /&gt;Console.Write("Enter a String to Test for Alphabets:");&lt;br /&gt;strToTest=Console.ReadLine();&lt;br /&gt;if(objValidate.IsAlpha(strToTest))&lt;br /&gt;{&lt;br /&gt;Console.WriteLine("{0} is Valid Alpha String",strToTest);&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;Console.WriteLine("{0} is not a Valid Alpha String",strToTest);&lt;br /&gt;}&lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;// Function to test for Positive Integers. &lt;br /&gt;public bool IsNaturalNumber(String strNumber)&lt;br /&gt;{&lt;br /&gt;Regex objNotNaturalPattern=new Regex("[^0-9]");&lt;br /&gt;Regex objNaturalPattern=new Regex("0*[1-9][0-9]*");&lt;br /&gt;return !objNotNaturalPattern.IsMatch(strNumber) &amp;&amp;&lt;br /&gt;objNaturalPattern.IsMatch(strNumber);&lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;// Function to test for Positive Integers with zero inclusive &lt;br /&gt;public bool IsWholeNumber(String strNumber)&lt;br /&gt;{&lt;br /&gt;Regex objNotWholePattern=new Regex("[^0-9]");&lt;br /&gt;return !objNotWholePattern.IsMatch(strNumber);&lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;// Function to Test for Integers both Positive &amp; Negative &lt;br /&gt;public bool IsInteger(String strNumber)&lt;br /&gt;{&lt;br /&gt;Regex objNotIntPattern=new Regex("[^0-9-]");&lt;br /&gt;Regex objIntPattern=new Regex("^-[0-9]+$|^[0-9]+$");&lt;br /&gt;return !objNotIntPattern.IsMatch(strNumber) &amp;&amp; objIntPattern.IsMatch(strNumber);&lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;// Function to Test for Positive Number both Integer &amp; Real &lt;br /&gt;public bool IsPositiveNumber(String strNumber)&lt;br /&gt;{&lt;br /&gt;Regex objNotPositivePattern=new Regex("[^0-9.]");&lt;br /&gt;Regex objPositivePattern=new Regex("^[.][0-9]+$|[0-9]*[.]*[0-9]+$");&lt;br /&gt;Regex objTwoDotPattern=new Regex("[0-9]*[.][0-9]*[.][0-9]*");&lt;br /&gt;return !objNotPositivePattern.IsMatch(strNumber) &amp;&amp;&lt;br /&gt;objPositivePattern.IsMatch(strNumber) &amp;&amp;&lt;br /&gt;!objTwoDotPattern.IsMatch(strNumber);&lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;// Function to test whether the string is valid number or not&lt;br /&gt;public bool IsNumber(String strNumber)&lt;br /&gt;{&lt;br /&gt;Regex objNotNumberPattern=new Regex("[^0-9.-]");&lt;br /&gt;Regex objTwoDotPattern=new Regex("[0-9]*[.][0-9]*[.][0-9]*");&lt;br /&gt;Regex objTwoMinusPattern=new Regex("[0-9]*[-][0-9]*[-][0-9]*");&lt;br /&gt;String strValidRealPattern="^([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]+$";&lt;br /&gt;String strValidIntegerPattern="^([-]|[0-9])[0-9]*$";&lt;br /&gt;Regex objNumberPattern =new Regex("(" + strValidRealPattern +")|(" + strValidIntegerPattern + ")");&lt;br /&gt;return !objNotNumberPattern.IsMatch(strNumber) &amp;&amp;&lt;br /&gt;!objTwoDotPattern.IsMatch(strNumber) &amp;&amp;&lt;br /&gt;!objTwoMinusPattern.IsMatch(strNumber) &amp;&amp;&lt;br /&gt;objNumberPattern.IsMatch(strNumber);&lt;br /&gt;} &lt;br /&gt;// Function To test for Alphabets. &lt;br /&gt;public bool IsAlpha(String strToCheck)&lt;br /&gt;{&lt;br /&gt;Regex objAlphaPattern=new Regex("[^a-zA-Z]");&lt;br /&gt;return !objAlphaPattern.IsMatch(strToCheck);&lt;br /&gt;}&lt;br /&gt;// Function to Check for AlphaNumeric.&lt;br /&gt;public bool IsAlphaNumeric(String strToCheck)&lt;br /&gt;{&lt;br /&gt;Regex objAlphaNumericPattern=new Regex("[^a-zA-Z0-9]");&lt;br /&gt;return !objAlphaNumericPattern.IsMatch(strToCheck); &lt;br /&gt;}&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-2757755958091719344?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/2757755958091719344/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2010/04/regular-expressions-and-c-net.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/2757755958091719344'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/2757755958091719344'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2010/04/regular-expressions-and-c-net.html' title='Regular Expressions and C#, .NET'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-1273599927397414397</id><published>2010-04-23T01:26:00.000-07:00</published><updated>2010-05-25T02:56:22.981-07:00</updated><title type='text'>Textbox Validation in C#.Net</title><content type='html'>For Numbers:&lt;br /&gt;&lt;br /&gt;Ex 1:&lt;br /&gt;&lt;br /&gt;if((e.KeyChar &gt; 47 &amp;&amp; e.KeyChar &lt; 58)||(e.KeyChar==46)||(e.KeyChar==8)){e.Handled = false;}else{e.Handled = true;MessageBox.Show("Please enter valid integer.");}Ex 2:string val = "0123456789";if (val.IndexOf(e.KeyChar)&lt;0&amp;&amp;e.KeyChar!= 8 &amp;&amp; e.KeyChar!=32){e.Handled = true;txtSid.Focus();}Ex 3: if (!Char.IsDigit(e.KeyChar))e.Handled=true;}For Letter:Ex 1.string val="abcdefghijklmnopqrstuvwxyz";if (val.IndexOf(e.KeyChar)&lt; 0 &amp;&amp; e.KeyChar!= 8 &amp;&amp; e.KeyChar!= 32){e.Handled = true;txtName.Focus();}For Email Id:string pattern=@"^[a-z][a-z|0-9|]*([_][a-z|0-9]+)*([.][a-z|" + @"0-9]+([_][a-z|0-9]+)*)?@[a-z][a-z|0-9|]*\.([a-z]" + @"[a-z|0-9]*(\.[a-z][a-z|0-9]*)?)$";System.Text.RegularExpressions.Match match = Regex.Match(txtEmail.Text.Trim(), pattern, RegexOptions.IgnoreCase);if(match.Success)MessageBox.Show("Success");elseMessageBox.Show("Fail");Using Javascript:if (document.getElementById("&lt;%=txtName.ClientID%&gt;").value=="")&lt;br /&gt;{&lt;br /&gt;alert("Name Feild can not be blank");&lt;br /&gt;document.getElementById("&lt;%=txtName.ClientID%&gt;").focus();&lt;br /&gt;return false;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-1273599927397414397?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/1273599927397414397/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2010/04/textbox-validation-in-cnet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/1273599927397414397'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/1273599927397414397'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2010/04/textbox-validation-in-cnet.html' title='Textbox Validation in C#.Net'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-3763722672163736213</id><published>2010-04-22T02:51:00.000-07:00</published><updated>2010-04-23T01:17:14.238-07:00</updated><title type='text'>C#.Net Coding Standards...</title><content type='html'>Pascal Casing - First character of all words are Upper Case and other characters are lower case. &lt;br /&gt;&lt;br /&gt;Example: BackColor&lt;br /&gt;&lt;br /&gt;Camel Casing - First character of all words, except the first word are Upper Case and other characters are &lt;br /&gt;&lt;br /&gt;lower case.&lt;br /&gt;Example: backColor&lt;br /&gt;&lt;br /&gt;1.Use Pascal casing for Class names &lt;br /&gt;&lt;br /&gt;public class HelloWorld&lt;br /&gt;{&lt;br /&gt;...&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;2.Use Pascal casing for Method names &lt;br /&gt;&lt;br /&gt;void SayHello(string name)&lt;br /&gt;{&lt;br /&gt;...&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;3.Use Camel casing for variables and method parameters &lt;br /&gt;&lt;br /&gt;int totalCount = 0;&lt;br /&gt;void SayHello(string name)&lt;br /&gt;{&lt;br /&gt;string fullMessage = "Hello " + name;&lt;br /&gt;...&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;4.Use the prefix “I” with Camel Casing for interfaces ( Example: IEntity )&lt;br /&gt;&lt;br /&gt;5.Do not use Hungarian notation to name variables. &lt;br /&gt;&lt;br /&gt;In earlier days most of the programmers liked it - having the data type as a prefix for the variable name and using m_ as prefix for member variables. Eg: &lt;br /&gt;&lt;br /&gt;string m_sName;&lt;br /&gt;int nAge;&lt;br /&gt;&lt;br /&gt;However, in .NET coding standards, this is not recommended. Usage of data type and m_ to represent member variables should not be used. All variables should use camel casing. &lt;br /&gt;&lt;br /&gt;Some programmers still prefer to use the prefix m_ to represent member variables, since there is no other easy way to identify a member variable.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;6.Use Meaningful, descriptive words to name variables. Do not use abbreviations. &lt;br /&gt;&lt;br /&gt;Good:&lt;br /&gt;&lt;br /&gt;string address&lt;br /&gt;int salary &lt;br /&gt;&lt;br /&gt;Not Good:&lt;br /&gt;&lt;br /&gt;string nam&lt;br /&gt;string addr&lt;br /&gt;int sal &lt;br /&gt;&lt;br /&gt;7.Do not use single character variable names like i, n, s etc. Use names like index, temp &lt;br /&gt;&lt;br /&gt;One exception in this case would be variables used for iterations in loops: &lt;br /&gt;&lt;br /&gt;for ( int i = 0; i &lt; count; i++ ){ ...}If the variable is used only as a counter for iteration and is not used anywhere else in the loop, many people still like to use a single char variable (i) instead of inventing a different suitable name. 8.Do not use underscores (_) for local variable names. 9.All member variables must be prefixed with underscore (_) so that they can be identified from other local variables.10.Do not use variable names that resemble keywords.11.Prefix boolean variables, properties and methods with “is” or similar prefixes.Ex: private bool _isFinished12.Namespace names should follow the standard pattern &lt;company name&gt;.&lt;product name&gt;.&lt;top level module&gt;.&lt;bottom level module&gt;&lt;br /&gt;&lt;br /&gt;13.File name should match with class name.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-3763722672163736213?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/3763722672163736213/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2010/04/cnet-coding-standards.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/3763722672163736213'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/3763722672163736213'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2010/04/cnet-coding-standards.html' title='C#.Net Coding Standards...'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-1431096879170840358</id><published>2010-03-19T01:22:00.000-07:00</published><updated>2010-03-19T01:24:24.825-07:00</updated><title type='text'>Introduction to Web Services</title><content type='html'>Its an application logic that can be exposed to internet and can be accessed by &lt;br /&gt;different web applications.&lt;br /&gt;&lt;br /&gt;web services represent a model in which discrete tasks within e-business processes are distributed widely throughout a value net.&lt;br /&gt;&lt;br /&gt;Web Services are platform-independent and language-independent, since they use standard XML languages. This means that my client program can be programmed in C++ and running under Windows, while the Web Service is programmed in Java and running under Linux.&lt;br /&gt;&lt;br /&gt;Most Web Services use HTTP for transmitting messages (such as the service request and response). This is a major advantage if you want to build an Internet-scale application, since most of the Internet's proxies and firewalls won't mess with HTTP traffic (unlike CORBA, which usually has trouble with firewalls).&lt;br /&gt;&lt;br /&gt;web services can be accessed programmatically. Unlike web sites and desktop applications, web services are not designed for direct human interaction, and they do not have a graphical user interface. Rather, web services operate at the code level; they are called by and exchange data with other software&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Core Layers of the Web Services Stack:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Simple Object Access Protocol (SOAP):&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;SOAP is a protocol for messaging and RPC-style communication between applications. It is based on XML and uses common Internet transport protocols like HTTP to carry its data. SOAP has been submitted to the World Wide Web Consortium (W3C) standards body and will emerge later this year as "XML Protocol (XP)".&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Extensible Markup Language (XML):&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;XML is a widely accepted format for exchanging data and its corresponding semantics. It is a fundamental building block for nearly every other layer in the web services stack.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Web Services Description Language (WSDL):&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;WSDL is an XML-based description of how to connect to a particular web service. A WSDL description abstracts a particular service's various connection and messaging protocols into a high-level bundle and forms a key element of the UDDI directory.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Universal Description, Discovery, and Integration (UDDI):&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;UDDI represents a set of protocols and a public directory for the registration and realtime lookup of web services and other business processes.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-1431096879170840358?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/1431096879170840358/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2010/03/introduction-to-web-services.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/1431096879170840358'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/1431096879170840358'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2010/03/introduction-to-web-services.html' title='Introduction to Web Services'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-9145772485116167131</id><published>2010-03-08T23:43:00.000-08:00</published><updated>2010-03-08T23:43:44.275-08:00</updated><title type='text'>ASP.NET Master Pages Overview</title><content type='html'>ASP.NET master pages allow you to create a consistent layout for the pages in your application. A single master page defines the look and feel and standard behavior that you want for all of the pages (or a group of pages) in your application. You can then create individual content pages that contain the content you want to display. When users request the content pages, they merge with the master page to produce output that combines the layout of the master page with the content from the content page.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;How Master Pages Work&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Master pages actually consist of two pieces, the master page itself and one or more content pages.&lt;br /&gt;&lt;br /&gt;Master Pages&lt;br /&gt;&lt;br /&gt;A master page is an ASP.NET file with the extension .master (for example, MySite.master) with a predefined layout that can include static text, HTML elements, and server controls. The master page is identified by a special @ Master directive that replaces the @ Page directive that is used for ordinary .aspx pages. The directive looks like the following.&lt;br /&gt;&lt;br /&gt;&lt;%@ Master Language="VB" %&gt;&lt;br /&gt;&lt;br /&gt;The @ Master directive can contain most of the same directives that a @ Control directive can contain. For example, the following master-page directive includes the name of a code-behind file, and assigns a class name to the master page.&lt;br /&gt;&lt;br /&gt;&lt;%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %&gt;&lt;br /&gt;&lt;br /&gt;In addition to the @ Master directive, the master page also contains all of the top-level HTML elements for a page, such as html, head, and form. For example, on a master page you might use an HTML table for the layout, an img element for your company logo, static text for the copyright notice, and server controls to create standard navigation for your site. You can use any HTML and any ASP.NET elements as part of your master page. &lt;br /&gt;&lt;br /&gt;Content Pages&lt;br /&gt;&lt;br /&gt;You define the content for the master page's placeholder controls by creating individual content pages, which are ASP.NET pages (.aspx files and, optionally, code-behind files) that are bound to a specific master page. The binding is established in the content page's @ Page directive by including a MasterPageFile attribute that points to the master page to be used. For example, a content page might have the following @ Page directive, which binds it to the Master1.master page.&lt;br /&gt;&lt;br /&gt;&lt;%@ Page Language="VB" MasterPageFile="~/MasterPages/Master1.master" Title="Content Page" %&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Advantages of Master Pages :&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Master pages provide functionality that developers have traditionally created by copying existing code, text, and control elements repeatedly; using framesets; using include files for common elements; using ASP.NET user controls; and so on. Advantages of master pages include the following:&lt;br /&gt;&lt;br /&gt;  * They allow you to centralize the common functionality of your pages so that you can make updates in just one place.&lt;br /&gt;  * They make it easy to create one set of controls and code and apply the results to a set of pages. For example, you can use controls on the master page to create a menu that applies to all pages.&lt;br /&gt;  * They give you fine-grained control over the layout of the final page by allowing you to control how the placeholder controls are rendered.&lt;br /&gt;  * They provide an object model that allows you to customize the master page from individual content pages.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-9145772485116167131?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/9145772485116167131/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2010/03/aspnet-master-pages-overview.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/9145772485116167131'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/9145772485116167131'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2010/03/aspnet-master-pages-overview.html' title='ASP.NET Master Pages Overview'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-338738831328699208</id><published>2010-03-08T23:39:00.000-08:00</published><updated>2010-03-08T23:39:28.656-08:00</updated><title type='text'>Validation in ASP.NET 2.0</title><content type='html'>Validation server controls are set of controls that enable you to work with the information your end users inputs into application. Application should always ensure that valid data is recorded. To ensure valid data is collected, we apply set of validations to data we collect. Validation is a set of rules that you apply to the data you collect. In this way, we can bring certain degree of discipline in end user. &lt;br /&gt;&lt;br /&gt;We can understand validation under two categories: Client side validation and Server side validation. Client side validation involves validating user input before the page is posted to server. Server side validation involves performing checks on server instead of client. This is most secure form but comes at cost of performance.&lt;br /&gt;&lt;br /&gt;ASP.NET introduced smart validation server controls to implement page level validations. They are capable of performing both server side and client side validations. So, Validation server controls offer the combined power of both approaches such that the security of application is never compromised. &lt;br /&gt;&lt;br /&gt;&lt;b&gt;ASP.NET 2.0 Validation server controls:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;    * RequiredFieldValidator&lt;br /&gt;    * CompareValidator&lt;br /&gt;    * RangeValidator&lt;br /&gt;    * RegularExpressionValidator&lt;br /&gt;    * CustomValidator&lt;br /&gt;    * ValidationSummary&lt;br /&gt;&lt;br /&gt;RequiredFieldValidator:&lt;br /&gt;&lt;br /&gt;The RequiredFieldValidator control is simple validation control which checks to see if the data is entered for the attached control. You can have a RequiredFieldValidator control for each form element on which you wish to enforce Mandatory Field rule.&lt;br /&gt;&lt;br /&gt;CompareValidator Server Control:&lt;br /&gt;&lt;br /&gt;The CompareValidator control allows you to make comparisons between two form elements as well as to compare values contained with in form element to constants that you specify. For instance, you can specify that a form's element value must be an integer and greater than a specified number. &lt;br /&gt;&lt;br /&gt;RangeValidator Server Control:&lt;br /&gt;&lt;br /&gt;The RangeValidator Server Control makes sure that the end user value or selection provided is between a specified ranges.&lt;br /&gt;&lt;br /&gt;RegularExpressionValidator Server Control:&lt;br /&gt;&lt;br /&gt;Using RegularExpressionValidator server control, you can check a user's input based on a pattern that you define using a regular expression. This means that you can define a structure that a user's input will be applied against to see if its structure matches the one that you define.&lt;br /&gt;&lt;br /&gt;CustomValidator Server Control:&lt;br /&gt;&lt;br /&gt;Sometimes, predefined Validation controls cannot address some of our critical requirements. You have to go beyond what they offer. This is where the CustomValidator control comes into play. The CustomValidator control allows you to build your own client-side or server-side validations that can then be easily applied to your web forms.&lt;br /&gt;&lt;br /&gt;ValidationSummary Server Control:&lt;br /&gt;&lt;br /&gt;The ValidationSummary control is reporting control, which is used by the other validation controls on a page. You can use this validation control to consolidate errors reporting for all the validation errors that occur on a page instead of leaving this up to each and every individual validation control.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-338738831328699208?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/338738831328699208/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2010/03/validation-in-aspnet-20.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/338738831328699208'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/338738831328699208'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2010/03/validation-in-aspnet-20.html' title='Validation in ASP.NET 2.0'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-1738124839295432697</id><published>2010-03-08T23:30:00.000-08:00</published><updated>2010-03-08T23:30:56.485-08:00</updated><title type='text'>Using WebParts in ASP.Net 2.0</title><content type='html'>It would not be wrong to say that Webparts are going to be the future of web based management systems. WebParts give us the option of dragging and dropping of objects on a page as well as, changing titles and border style properties of objects at runtime. Before the introduction of WebParts it was used to be a hectic task because we had to write a lot of JavaScript and had to save the state of objects in a database.&lt;br /&gt;&lt;br /&gt;There are two basic things in WebParts:&lt;br /&gt;&lt;br /&gt;    * WebPart manager&lt;br /&gt;    * WebPart zones&lt;br /&gt;&lt;br /&gt;&lt;b&gt;WebPartManager&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The WebPartManager is the manager for all webparts. If you use webparts in your web projects you are required to use the WebPartManager. Usually you just drag and drop this into your webform and are ready to go.&lt;br /&gt;WebPart Zones&lt;br /&gt;&lt;br /&gt;There are four kinds of zones in webpart zones:&lt;br /&gt;&lt;br /&gt;    * WebPart Zone&lt;br /&gt;    * Editor Zone&lt;br /&gt;    * Catalog Zone&lt;br /&gt;    * Connection Zone&lt;br /&gt;&lt;br /&gt;&lt;b&gt;WebPart Zone&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The webpart Zone is the basic unit for webparts. By placing different contents in a webpart zone we can allow a user to drag and drop contents on a page.&lt;br /&gt;&lt;br /&gt;To use different zones add a dropdownlist to your webform and add the following items to it.&lt;br /&gt;&lt;br /&gt;    * Browse&lt;br /&gt;    * Display&lt;br /&gt;    * Edit&lt;br /&gt;    * Catalog&lt;br /&gt;    * Connect&lt;br /&gt;&lt;br /&gt;Paste the following code in the SelectedIndexChanged event of the dropdownlist (this assumes the dropdownlist’s id is cmbOptions and the webpart Manager’s id is WebPartManager1).&lt;br /&gt;&lt;br /&gt;if (cmbOptions.SelectedValue == "Design")&lt;br /&gt;{&lt;br /&gt;  WebPartManager1.DisplayMode = WebPartManager.DesignDisplayMode;&lt;br /&gt;}&lt;br /&gt;else if (cmbOptions.SelectedValue == "Browse")&lt;br /&gt;{&lt;br /&gt;  WebPartManager1.DisplayMode = WebPartManager.BrowseDisplayMode;&lt;br /&gt;}&lt;br /&gt;else if (cmbOptions.SelectedValue == "Catalog")&lt;br /&gt;{&lt;br /&gt;  WebPartManager1.DisplayMode = WebPartManager.CatalogDisplayMode;&lt;br /&gt;}&lt;br /&gt;else if (cmbOptions.SelectedValue == "Edit")&lt;br /&gt;{&lt;br /&gt;  WebPartManager1.DisplayMode = WebPartManager.EditDisplayMode;&lt;br /&gt;}&lt;br /&gt;else if (cmbOptions.SelectedValue == "Connect")&lt;br /&gt;{&lt;br /&gt;  WebPartManager1.DisplayMode = WebPartManager.ConnectDisplayMode;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Browse mode&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The Browse mode is the default mode of webparts. In Browse mode we can not drag and drop the webparts but we can see two options, minimize and close. Minimizing a webpart will still display it in minimized state.If you choose close then it can only be restored while being in catalog mode.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Design mode&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;In design mode we can drag drop objects between webparts. There are two webparts named as Links and Search. The following screenshot shows the Links webpart being dragged over the Search one. &lt;br /&gt;&lt;br /&gt;&lt;b&gt;Edit Mode&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;The edit mode is used to edit webparts at runtime. Editing a webpart is further divided into four types: Appearance, Behavior, Property and Layout. We will first see how to use the Appearance and LayoutEditorPart.&lt;br /&gt;AppearanceEditorPart and LayoutEditorPart&lt;br /&gt;&lt;br /&gt;First, place an editor zone into the web form. Then place an AppearanceEditorPart and LayoutEditorPart inside the editor zone. Run the application and select the edit mode from the dropdownlist. Click edit from the menu available for webparts. &lt;br /&gt;&lt;br /&gt;&lt;b&gt;PropertyGridEditorPart&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;By using the property editor we can change the properties of the objects in our webparts. In our example we are going to change the CSSClass property of the object. To use this we will follow the same method as explained in the AppearanceEditorPart and LayoutEditorPart section.&lt;br /&gt;&lt;br /&gt;Place an editor zone into the web form. Then place a PropertyGridEditorPart inside the editor zone. To use the editor zone add a new user control into your project. Place a textbox in the user control and place this user control inside the webpart of the web form. In the code behind of user control paste the following code.&lt;br /&gt;&lt;br /&gt;string _cssClass = "FrmTxtBox";&lt;br /&gt;[WebBrowsable(), Personalizable(true)]&lt;br /&gt;public string CssClass&lt;br /&gt;{&lt;br /&gt;  get { return _cssClass; }&lt;br /&gt;  set { TextBox1.CssClass= value; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;protected void Page_Load(Object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;  TextBox1.CssClass = CssClass;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;The above code changes the CssClass of the TextBox. This property will now be available in the webparts edit mode and we will be able to change this at run-time as well. Besides setting the CssClass we have also used two additional attributes in the class declaration:&lt;br /&gt;&lt;br /&gt;    * WebBrowsable - It allows a webpart to display a user defined property in edit mode.&lt;br /&gt;    * Personalizable - It allows a property to be editable.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Catalog mode&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The Catalog mode gives us the option to add/remove webparts at runtime. For example if we have few modules like weather, news, shopping, horoscope etc. and want to give the user an option to show or hide these modules at runtime, we can accomplish this task using the catalog mode.&lt;br /&gt;&lt;b&gt;&lt;br /&gt;CatalogZone&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;The CatalogZone is divided into three subtypes: PageCatalogPart, DeclarativeCatalogPart and ImportCatalogPart. On the webform add a CatalogZone and add the previous mentioned three types into it. We can show webparts with the help of the Pagecatalog which are closed by using the close option of the webpart.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-1738124839295432697?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/1738124839295432697/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2010/03/using-webparts-in-aspnet-20.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/1738124839295432697'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/1738124839295432697'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2010/03/using-webparts-in-aspnet-20.html' title='Using WebParts in ASP.Net 2.0'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-8052902891452536175</id><published>2010-03-08T23:21:00.000-08:00</published><updated>2010-03-08T23:24:09.147-08:00</updated><title type='text'>Building an ASP.NET Shopping Cart Using DataTables</title><content type='html'>Most dynamic Web applications are created for the sole purpose of making money on the Web.&lt;br /&gt;&lt;br /&gt;Let's face it: why would you go through all the work of creating a dynamic Web application if you don't plan to make money through it? Sure, companies employ dynamic intranet sites and there are still some -- although very few -- free Web applications you can use.&lt;br /&gt;&lt;br /&gt;In the real world, however, dynamic Web applications are created in an attempt to make money by allowing site owners to sell merchandise on the Web. Providing users with the capability to add items to a virtual shopping cart as they browse through your Website is still very much a business that commands good money. Companies such as VeriSign, Paypal, WebAssist, and LinkPoint charge to provide developers with the capability to add shopping cart functionality to their own Websites. But why pay $300-$400 for a solution that someone else already built, when you can build one just as easily yourself utilizing new technology in ASP.NET, for free?&lt;br /&gt;&lt;br /&gt;This article will allow you to develop and implement your own shopping cart utilizing a Session, a DataGrid, and the DataTable class of the DataSet object. Through this article, you'll learn to:&lt;br /&gt;&lt;br /&gt;* Build a user interface using ASP.NET Web Server Controls&lt;br /&gt;* Dynamically construct a DataTable depending on user interaction&lt;br /&gt;* Bind the dynamically constructed DataTable to a DataGrid&lt;br /&gt;* Allow the user to remove items from the cart freely&lt;br /&gt;* Keep a running cost total of items within the cart&lt;br /&gt;&lt;br /&gt;At the end of this article, you'll have a fully functioning shopping cart, and you'll have gained a thorough understanding of DataTables, DataGrids, and Session Variables&lt;br /&gt;&lt;br /&gt;This project is separated into five parts:&lt;br /&gt;&lt;br /&gt;1. Building the user interface&lt;br /&gt;&lt;br /&gt;2. Building the DataTable structure&lt;br /&gt;&lt;br /&gt;3. Adding items to the cart&lt;br /&gt;&lt;br /&gt;4. Keeping a running total&lt;br /&gt;&lt;br /&gt;5. Removing items from the cart&lt;br /&gt;&lt;br /&gt;Step 1: Building the Shopping Cart User Interface&lt;br /&gt;&lt;br /&gt;The user interface or UI for the application is quite simple. In fact, most of the interaction will occur within the DataGrid, but the UI does include some key components that the user will be interacting with:&lt;br /&gt;&lt;br /&gt;* A DropDownList Web control that will display the products that we'll offer. The cost of each item will be associated with the value of the DropDownList Web control for simplicity's sake.&lt;br /&gt;* A TextBox Web control that offers the user the ability to adjust quantities&lt;br /&gt;* A Button Web control to add to the cart&lt;br /&gt;* A DataGrid that will contain the cart's contents&lt;br /&gt;* A Label control that will display to the user a running total in terms of price&lt;br /&gt;&lt;br /&gt;Now that you have an idea of what the UI will display, let's add these components to the body of an HTML page. Using Dreamweaver MX, we'll create a new page and add this code into the &lt;body&gt; tag of the page:&lt;br /&gt;&lt;br /&gt;&lt;form runat="server"&gt;Product:&lt;br /&gt;&lt;br /&gt;&lt;asp:DropDownList id="ddlProducts" runat="server"&gt;&lt;br /&gt;&lt;asp:ListItem Value="4.99"&gt;Socks&lt;/asp:ListItem&gt;&lt;br /&gt;&lt;asp:ListItem Value="34.99"&gt;Pants&lt;/asp:ListItem&gt;&lt;br /&gt;&lt;asp:ListItem Value="14.99"&gt;Shirt&lt;/asp:ListItem&gt;&lt;br /&gt;&lt;asp:ListItem Value="12.99"&gt;Hat&lt;/asp:ListItem&gt;&lt;br /&gt;&lt;/asp:DropDownList&gt;&lt;br /&gt;&lt;br /&gt;Quantity:&lt;br /&gt;"&lt;br /&gt;&lt;asp:textbox id="txtQuantity" runat="server" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;asp:Button id="btnAdd" runat="server" Text="Add To Cart"  onClick="AddToCart" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;asp:DataGrid id="dg" runat="server" /&gt;&lt;br /&gt;&lt;br /&gt;Total:  &lt;br /&gt;&lt;asp:Label id="lblTotal" runat="server" /&gt;&lt;br /&gt;" &lt;br /&gt;The code is actually quite simple and needs very little explanation. Basically, a hard-coded DropDownList control (ddlProducts) is added, with four products. The cost of those products is maintained by associating a decimal value for each specific product.&lt;br /&gt;&lt;br /&gt;Second, a TextBox control (txtQuantity) is added so that the user can modify quantities. Next, a Button control (btnAdd) is added with the text "Add to Cart". The onClick event associated with the Button control will call the AddToCart() subroutine, which will be created in the next section.&lt;br /&gt;&lt;br /&gt;Next, a DataGrid (dg) is added which will be used to bind to the dynamically constructed DataTable. Remember, the DataTable will be constructed in code, and bound to the DataGrid for presentation to the user. We'll add a button column to allow the user to remove a specific item if he or she wishes a little later. Finally, we'll add a Label control (lblTotal), which will be used to display to the user a running total of the items within the cart.&lt;br /&gt;Step 2: Building the DataTable Structure&lt;br /&gt;&lt;br /&gt;If you're familiar with DataSets, then you know that DataTables provide you with a way to dynamically create a purely memory-resident representation of a database table. Typically, you'd fill a DataTable from an existing database, but you could also create one programmatically, as will be the case here.&lt;br /&gt;&lt;br /&gt;In a DataTable, columns are represented by the columns property, and rows are represented by the rows property. Thus, DataTables will be the perfect choice for the creation of our shopping cart. We can build the columns just as we would within a database, using the columns property of the DataTable, and add rows to the DataTable with the Rows property. With the DataTable built, we can then bind the DataTable to a DataGrid to display the results in an intuitive manner.&lt;br /&gt;&lt;br /&gt;Because DataTables contain rows and columns, you will be able to effectively mock the structure of a conventional database table. The rows will be added to the DataTable as the user adds items to the cart. For now, we'll need to construct the columns that will serve as the categories for the row items. In order for the cart to function correctly, we'll need to add the following columns with a corresponding data type:&lt;br /&gt;&lt;br /&gt;You're probably wondering how data types, auto increment, and uniqueness will be set programmatically. Remember, DataTables contain column and row properties. Some of those properties include the ability to set the above mentioned items, just as you would a traditional database table. You'll also notice that the DataTable contains a column for ID. Technically, this column has nothing to do with the shopping cart, but it will have a lot to do with keeping the items in the cart unique, and will allow us to establish a primary key if we ever want to create a relationship with another DataTable.&lt;br /&gt;&lt;br /&gt;For now we just want the structure of the DataTable built when the page loads for the first time. We don't want to actually start to define rows until the user selects an item to add to the cart.&lt;br /&gt;&lt;br /&gt;To begin building the cart's structure, add this code into the head of your page:&lt;br /&gt;&lt;br /&gt;Dim objDT As System.Data.DataTable  &lt;br /&gt;Dim objDR As System.Data.DataRow&lt;br /&gt;&lt;br /&gt;Private Sub Page_Load(s As Object, e As EventArgs)&lt;br /&gt;    If Not IsPostBack Then&lt;br /&gt;         makeCart()&lt;br /&gt;    End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Function makeCart()&lt;br /&gt;    objDT = New System.Data.DataTable("Cart")&lt;br /&gt;    objDT.Columns.Add("ID", GetType(Integer))&lt;br /&gt;    objDT.Columns("ID").AutoIncrement = True&lt;br /&gt;    objDT.Columns("ID").AutoIncrementSeed = 1&lt;br /&gt;&lt;br /&gt;    objDT.Columns.Add("Quantity", GetType(Integer))&lt;br /&gt;    objDT.Columns.Add("Product", GetType(String))&lt;br /&gt;    objDT.Columns.Add("Cost", GetType(Decimal))&lt;br /&gt; &lt;br /&gt;    Session("Cart") = objDT&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;Looking at the code, you can see, that the makeCart() function is called only when the page is loaded for the first time. This is the reason for the IsPostBack check.&lt;br /&gt;&lt;br /&gt;Within the makeCart() function, we'll add the code that defines the actual structure for the DataTable and its columns. First, we add a column to the DataTable named ID, assigning it the data type for integer. We assign the property for AutoIncrement to True, and begin the seed at 1.&lt;br /&gt;&lt;br /&gt;Next, add three more columns to the DataTable for Quantity, Product, and Cost, assigning them the data types for integer, string, and decimal respectively. Finally, the DataTable is added into a Session conveniently named "Cart", for storage.&lt;br /&gt;&lt;br /&gt;That's it! If you think about the structure of a database table and then consider the structure and code for the DataTable, they begin to resemble each other conceptually. The next step involves adding items to the cart, which is no harder than defining new rows for the DataTable.&lt;br /&gt;&lt;br /&gt;Step 3: Building the Add to Cart Functionality&lt;br /&gt;&lt;br /&gt;Now that the structure of the DataTable has been completely built, we'll want to begin to add to the cart the specific items that the user selects from the drop down menu. Again, to do this, we simply construct new rows and add them to the appropriate position within the DataTable cart. To construct the Add to Cart functionality, add the code below:&lt;br /&gt;&lt;br /&gt;Sub AddToCart(s As Object, e As EventArgs)  &lt;br /&gt;&lt;br /&gt;objDT = Session("Cart")  &lt;br /&gt;Dim Product = ddlProducts.SelectedItem.Text  &lt;br /&gt;&lt;br /&gt;objDR = objDT.NewRow  &lt;br /&gt;objDR("Quantity") = txtQuantity.Text  &lt;br /&gt;objDR("Product") = ddlProducts.SelectedItem.Text  &lt;br /&gt;objDR("Cost") = Decimal.Parse(ddlProducts.SelectedItem.Value)  &lt;br /&gt;objDT.Rows.Add(objDR)  &lt;br /&gt;Session("Cart") = objDT  &lt;br /&gt;&lt;br /&gt;dg.DataSource = objDT  &lt;br /&gt;dg.DataBind()  &lt;br /&gt;&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;You'll remember that the Button control had the onClick event that called the AddToCart() subroutine. This subroutine contains all the code that's necessary to retrieve an existing cart from the Session object if it exists, add new items to the cart, place the cart back into the session, and finally, bind to the DataGrid.&lt;br /&gt;&lt;br /&gt;As I mentioned, the first two lines of code retrieve the cart from the session if it exists, and retrieve the product selected from the drop down menu. As you have already created a new instance of the DataRow class, you can create the new rows for the specific columns within the DataTable.&lt;br /&gt;&lt;br /&gt;You'll notice that we set the Quantity column equal to the value of the quantity text box control, and set the Product column equal to the text value of the drop down menu selection. We then convert the value of the drop down menu, which is cost, into a decimal value for the cost column. Finally, we add the new row to the DataTable, add the DataTable to the Session, or overwrite it if it already exists, and bind the DataTable to the DataGrid.&lt;br /&gt;&lt;br /&gt;Test what you have so far in the browser. It should work fine, except for one problem. You'll see that if you select an item, add it to the cart, and then select the same item again, rather than adding the sum of the old quantity with the new quantity, it just creates a new row. You can fix this problem by modifying the AddToCart() subroutine. Just below the code where you retrieve the item from the drop down menu, add the following loop to check within the DataTable for an existing product:&lt;br /&gt;&lt;br /&gt;Dim blnMatch As Boolean = False  &lt;br /&gt;&lt;br /&gt;For Each objDR In objDT.Rows  &lt;br /&gt;If objDR("Product") = Product Then  &lt;br /&gt;objDR("Quantity") += txtQuantity.Text  &lt;br /&gt;blnMatch = True  &lt;br /&gt;Exit For  &lt;br /&gt;End If  &lt;br /&gt;Next&lt;br /&gt;&lt;br /&gt;Now wrap the new code that adds a new row within a conditional statement.&lt;br /&gt;&lt;br /&gt;If Not blnMatch Then  &lt;br /&gt;objDR = objDT.NewRow  &lt;br /&gt;objDR("Quantity") = Int32.Parse(txtQuantity.Text)  &lt;br /&gt;objDR("Product") = ddlProducts.SelectedItem.Text  &lt;br /&gt;objDR("Cost") = Decimal.Parse(ddlProducts.SelectedItem.Value)  &lt;br /&gt;objDT.Rows.Add(objDR)  &lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;Basically, a new row will only be created if the product is not found within the cart. If it is found, however, it will simply adjust the quantity by whatever the user places into the quantity textbox control.&lt;br /&gt;Step 4: Keeping the Order Total&lt;br /&gt;&lt;br /&gt;The next step will be to build the function that keeps a running total of the cost of the items within the cart. This will be used to present the user with a working total as they add and remove items in the cart. You can add this functionality using the code below:&lt;br /&gt;&lt;br /&gt;Function GetItemTotal() As Decimal  &lt;br /&gt;&lt;br /&gt;Dim intCounter As Integer  &lt;br /&gt;Dim decRunningTotal As Decimal  &lt;br /&gt;&lt;br /&gt;For intCounter = 0 To objDT.Rows.Count -- 1  &lt;br /&gt;objDR = objDT.Rows(intCounter)  &lt;br /&gt;decRunningTotal += (objDR("Cost") * objDR("Quantity"))  &lt;br /&gt;Next  &lt;br /&gt;&lt;br /&gt;Return decRunningTotal  &lt;br /&gt;&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;You can see that this function simply loops through the rows in the DataTable, multiplies the quantity column by the cost column, and returns the result. The first step involves defining the functon. As you want to return a decimal value, make sure you define the function as a decimal. Next, we'll create two new variables: one as an integer and one as a decimal. Next, you loop through the rows within the DataTable and multiply the cost column for a specific row by the quantity for that row, and store it within the decRunningTotal variable. Finally, we'll return the value.&lt;br /&gt;&lt;br /&gt;The last step will be to write the value of the function into the label control. Add the following line to the end of the btnAddToCart subroutine -- this effectively writes the cost into the label control:&lt;br /&gt;&lt;br /&gt;lblTotal.Text = "$" &amp; GetItemTotal()&lt;br /&gt;&lt;br /&gt;Save your work and run it in a browser. This time, as you add items to the cart, a total is presented within the label control. Fantastic! Now, the last part we'll discuss involves removing items from the cart.&lt;br /&gt;Step 5: Removing Items from the Cart&lt;br /&gt;&lt;br /&gt;Now that a working model of the shopping cart has been constructed, we'll want to add the next bit of functionality: removing items from the cart. Obviously you can see the importance of this: you want users to be able to add and remove any and all items to or from the shopping cart as required. Add the functionality for removing items from the cart using the following subroutine:&lt;br /&gt;&lt;br /&gt;Sub Delete_Item(s As Object, e As DataGridCommandEventArgs)  &lt;br /&gt;&lt;br /&gt;objDT = Session("Cart")  &lt;br /&gt;objDT.Rows(e.Item.ItemIndex).Delete()  &lt;br /&gt;Session("Cart") = objDT  &lt;br /&gt;&lt;br /&gt;dg.DataSource = objDT  &lt;br /&gt;dg.DataBind()  &lt;br /&gt;&lt;br /&gt;lblTotal.Text = "$" &amp; GetItemTotal()  &lt;br /&gt;&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;This subroutine, which we'll associate with the DataGrid in a minute, simply dumps the contents of the session into a new DataTable object, deletes the specific row that a user clicked, and then places the revised DataTable back into the Session variable for storage. Finally we re-bind to the DataGrid and update the total by calling the GetItemTotal() function.&lt;br /&gt;&lt;br /&gt;You'll want to note that one of the parameters being passed into the subroutine is that of the DataGridCommandEventArgs. Without this parameter, we wouldn't be able to determine which item within the DataGrid the user selected.&lt;br /&gt;&lt;br /&gt;The last step will be to modify the DataGrid. You will need to add a new button column, as well as a new event, to call the Delete_Item subroutine. The new DataGrid should resemble the following code:&lt;br /&gt;&lt;br /&gt;&lt;asp:DataGrid id=dg runat="server"  ondeletecommand="Delete_Item"&gt;  &lt;br /&gt;&lt;columns&gt;  &lt;br /&gt;&lt;asp:buttoncolumn buttontype="LinkButton"  commandname="Delete" text="Remove Item" /&gt;  &lt;br /&gt;&lt;/columns&gt;  &lt;br /&gt;&lt;/asp:DataGrid&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-8052902891452536175?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/8052902891452536175/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2010/03/building-aspnet-shopping-cart-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/8052902891452536175'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/8052902891452536175'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2010/03/building-aspnet-shopping-cart-using.html' title='Building an ASP.NET Shopping Cart Using DataTables'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-5471653906080273605</id><published>2010-03-08T23:12:00.001-08:00</published><updated>2010-03-08T23:12:51.444-08:00</updated><title type='text'>ASP.NET Web.config File</title><content type='html'>Applications of XML have been integrated into .NET to such an extent that XML is hardly a buzzword anymore. Microsoft, as you probably know, has taken XML into the core of its .NET framework. Not only is XML a generally accepted format for the exchange of data, it's also used to store configuration settings.&lt;br /&gt;&lt;br /&gt;Configuration settings for any of your ASP.NET Web applications can be stored in a simple text file. Presented in an easily understandable XML format, this file, called Web.config, can contain application-wide data such as database connection strings, custom error messages, and culture settings.&lt;br /&gt;&lt;br /&gt;Because the Web.config is an XML file, it can consist of any valid XML tags, but the root element should always be &lt;configuration&gt;. Nested within this tag you can include various other tags to describe your settings. Since a Web.config file comes as a standard when you start to build a new Web application, let's look at the default XML file generated by Visual Studio .NET:&lt;br /&gt;&lt;br /&gt;&lt;?xml version="1.0" encoding="utf-8" ?&gt;&lt;br /&gt;&lt;configuration&gt;&lt;br /&gt; &lt;system.web&gt;&lt;br /&gt;   &lt;compilation          defaultLanguage="c#"        debug="true"   /&gt;&lt;br /&gt;   &lt;customErrors     mode="RemoteOnly"     /&gt;  &lt;br /&gt;   &lt;authentication mode="Windows" /&gt;  &lt;br /&gt;   &lt;authorization&gt;&lt;br /&gt;       &lt;allow users="*" /&gt;&lt;br /&gt;   &lt;/authorization&gt;&lt;br /&gt;   &lt;trace       enabled="false"       requestLimit="10"       pageOutput="false"       traceMode="SortByTime"   localOnly="true"   /&gt;&lt;br /&gt;   &lt;sessionState             mode="InProc"           stateConnectionString="tcpip=127.0.0.1:42424"           sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"           cookieless="false"             timeout="20"     /&gt;&lt;br /&gt;   &lt;globalization             requestEncoding="utf-8"             responseEncoding="utf-8"    /&gt;&lt;br /&gt;   &lt;br /&gt;&lt;/system.web&gt;&lt;br /&gt;&lt;br /&gt;&lt;/configuration&gt;&lt;br /&gt;&lt;br /&gt;Experienced ASP.NET programmers will have noticed that I've left out the comment tags that are generated automatically with the file. I've done that to provide a clear view of the XML that's used here. Also, I'll elaborate on each configuration tag later in this article, and this discussion will make the comment tags rather obsolete.&lt;br /&gt;&lt;br /&gt;If you look at the example XML, you'll notice that the &lt;configuration&gt; tag has only one child tag, which we call section group, the &lt;system.web&gt; tag. A section group typically contains the setting sections, such as: compilation, customErrors, authentication, authorization, etc. The way this works is pretty straightforward: you simply include your settings in the appropriate setting sections. If, for example, you wanted to use a different authentication mode for your Web application, you'd change that setting in the authentication section.&lt;br /&gt;&lt;br /&gt;Apart from the standard system.web settings, you can define your own specific application settings, such as a database connection string, using the &lt;appSettings&gt; tag. Consequently, your most common Web.config outline would be:&lt;br /&gt;&lt;br /&gt;&lt;configuration&gt;&lt;br /&gt; &lt;system.web&gt;&lt;br /&gt;   &lt;!— sections--&gt;    &lt;br /&gt; &lt;/system.web&gt;&lt;br /&gt; &lt;appSettings&gt;&lt;br /&gt;   &lt;!— sections --&gt;    &lt;br /&gt; &lt;/appSettings &gt;&lt;br /&gt;&lt;/configuration&gt;&lt;br /&gt;&lt;br /&gt;Let's discuss the details of both section groups now.&lt;br /&gt;The system.web Section Group&lt;br /&gt;&lt;br /&gt;In this section group, you'll typically include configuration settings that, in the pre-.NET era, you'd have set up somewhere in the IIS administration console. At Microsoft's MSDN Library, you can find an overview of all the tags that the system.web section group understands, but, depending on the complexity of your site, you may not ever use even half of those options.&lt;br /&gt;&lt;br /&gt;Let's have a look at the most valuable tweaks you can make within the system.web section group, in alphabetical order.&lt;br /&gt;&lt;br /&gt;&lt;authentication&gt;&lt;br /&gt;&lt;br /&gt;The authentication section controls the type of authentication used within your Web application, as contained in the attribute mode. You'll enter the value "None" if anyone may access your application. If authentication is required, you'll use "Windows", "Forms" or "Passport" to define the type of authentication. For example:&lt;br /&gt;&lt;br /&gt;   &lt;authentication mode="Windows" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;authorization&gt;&lt;br /&gt;&lt;br /&gt;To allow or deny access to your web application to certain users or roles, use &lt;allow&gt; or &lt;deny&gt; child tags.&lt;br /&gt;&lt;br /&gt;   &lt;authorization&gt;&lt;br /&gt;       &lt;allow roles="Administrators,Users" /&gt;&lt;br /&gt;       &lt;deny users="*" /&gt;&lt;br /&gt;   &lt;/authorization&gt;&lt;br /&gt;&lt;br /&gt;It's important to understand that ASP.NET's authorization module iterates through the sections, applying the first rule that corresponds to the current user. In this example, users carrying the role Administrators or Users will be allowed access, while all others (indicated by the * wildcard) will encounter the second rule and will subsequently be denied access.&lt;br /&gt;&lt;br /&gt;&lt;compilation&gt;&lt;br /&gt;&lt;br /&gt;Here, you can configure the compiler settings for ASP.NET. You can use loads of attributes here, of which the most common are debug and defaultLanguage. Set debug to "true" only if you want the browser to display debugging information. Since turning on this option reduces performance, you'd normally want to set it to "false". The defaultLanguage attribute tells ASP.NET which language compiler to use, since you could use either Visual Basic .NET or C# for instance. It has value vb by default. &lt;br /&gt;&lt;br /&gt;&lt;customErrors&gt;&lt;br /&gt;&lt;br /&gt;To provide your end users with custom, user-friendly error messages, you can set the mode attribute of this section to On. If you set it to RemoteOnly, custom errors will be shown only to remote clients, while local host users will see the ugly but useful ASP.NET errors -- clearly, this is helpful when debugging. Setting the mode attribute to Off will show ASP.NET errors to all users.&lt;br /&gt;&lt;br /&gt;If you supply a relative (for instance, /error404.html) or absolute address (http://yourdomain.com/error404.html) in the defaultRedirect attribute, the application will be automatically redirected to this address in case of an error. Note that the relative address is relative to the location of the Web.config file, not the page in which the error takes place. In addition you can use &lt;error&gt; tags to provide a statusCode and a redirect attribute:&lt;br /&gt;&lt;br /&gt;   &lt;customErrors mode="RemoteOnly" defaultRedirect="/error.html"&gt;&lt;br /&gt;       &lt;error statusCode="403" redirect="/accessdenied.html" /&gt;&lt;br /&gt;       &lt;error statusCode="404" redirect="/pagenotfound.html" /&gt;&lt;br /&gt;   &lt;/customErrors&gt;&lt;br /&gt;&lt;br /&gt;&lt;globalization&gt;&lt;br /&gt;&lt;br /&gt;The globalization section is useful when you want to change the encoding or the culture of your application. Globalization is such an extensive subject that an entire article could be dedicated to the matter. In short, this section allows you to define which character set the server should use to send data to the client (for instance UTF-8, which is the default), and which settings the server should use to interpret and displaying culturally specific strings, such as numbers and dates.&lt;br /&gt;&lt;br /&gt;   &lt;globalization requestEncoding="utf-8" responseEncoding="utf-8"         culture="nl-NL" /&gt;&lt;br /&gt;&lt;br /&gt;Encoding is done through the attributes requestEncoding and responseEncoding. The values should be equal in all one-server environments. In this example, the application culture is set to Dutch. If you don't supply a culture, the application will use the server's regional settings.&lt;br /&gt;&lt;br /&gt;&lt;httpRuntime&gt;&lt;br /&gt;&lt;br /&gt;You can use the httpRuntime section to configure a number of general runtime settings, two of which are particularly convenient.&lt;br /&gt;&lt;br /&gt;   &lt;httpRuntime appRequestQueueLimit="100" executionTimeout="600" /&gt;&lt;br /&gt;&lt;br /&gt;The first attribute specifies the number of requests the server may queue in memory at heavy-traffic times. In the example, if there are already 100 requests waiting to be processed, the next request will result in a 503 error ("Server too busy").&lt;br /&gt;&lt;br /&gt;The executionTimeout attribute indicates the number of seconds for which ASP.NET may process a request before it's timed out.&lt;br /&gt;&lt;br /&gt;&lt;sessionState&gt;&lt;br /&gt;&lt;br /&gt;In this section of the Web.config file, we tell ASP.NET where to store the session state. The default is in the process self:&lt;br /&gt;&lt;br /&gt;   &lt;sessionState mode="InProc" /&gt;&lt;br /&gt;&lt;br /&gt;Session variables are very powerful, but they have a few downsides. Information is lost when the ASP.NET process crashes, and sessions are generally useless in the case of a Web farm (multiple Web servers). In that instance, a shared session server can solve your issues. It's beyond the scope of this article to expand on this topic, but it's worth a mention. More information on sessionState can be found in the MSDN Library online.&lt;br /&gt;&lt;br /&gt;&lt;trace&gt;&lt;br /&gt;&lt;br /&gt;Your application's trace log is located in the application root folder, under the name trace.axd. You can change the display of tracing information in the trace section.&lt;br /&gt;&lt;br /&gt;The attributes you will look for initially are enabled: localOnly, and pageOutput.&lt;br /&gt;&lt;br /&gt;   &lt;trace enabled="true" localOnly="true" pageOutput="false" /&gt;&lt;br /&gt;&lt;br /&gt;Set localOnly to "false" to access the trace log from any client. If you set the value of pageOutput to "true", tracing information will be added to the bottom of each Web page.&lt;br /&gt;The appSettings Section Group&lt;br /&gt;&lt;br /&gt;Apart from the Website configuration settings I've been talking about in the preceding paragraphs, you'll know that a programmer frequently likes to use custom application-wide constants to store information over multiple pages. The most appealing example of such a custom constant is a database connection string, but you can probably think of dozens more from your own experience.&lt;br /&gt;&lt;br /&gt;The common denominator of these constants is that you want to retrieve their values programmatically from your code. The Web.config file provides the possibility to do so, but as a security measure, these constants have to be included in the &lt;appSettings&gt; section group. Just like &lt;system.web&gt;, &lt;appSettings&gt; is a direct child tag of the Web.config's configuration root.&lt;br /&gt;&lt;br /&gt;A typical custom section group would look something like this:&lt;br /&gt;&lt;br /&gt;   &lt;appSettings&gt;&lt;br /&gt;       &lt;add key="sqlConn" value="Server=myPc;Database=Northwind" /&gt;&lt;br /&gt;       &lt;add key="smtpServer" value="smtp.mydomain.com" /&gt;&lt;br /&gt;   &lt;/appSettings&gt;&lt;br /&gt;&lt;br /&gt;The example shows that keys and values can be included in the custom application settings via an &lt;add&gt; tag. The way to access such a value in any of your Web pages is illustrated below:&lt;br /&gt;&lt;br /&gt;   ConfigurationSettings.AppSettings("sqlConn")&lt;br /&gt;&lt;br /&gt;Yes, it's as easy as that! Note that the value of these settings is always a String format.&lt;br /&gt;A Few Other Issues&lt;br /&gt;&lt;br /&gt;I won't go into them here, but the Web.config file can contain several other section groups besides the aforementioned system.web and appSettings, such as the configSettings group.&lt;br /&gt;&lt;br /&gt;    * A Web application can contain more than one Web.config file. The settings in a file apply to the directory in which it's located, and all child directories. Web.config files in child directories take precedence over the settings that are specified in parent directories.&lt;br /&gt;    * Web.config files are protected by IIS, so clients cannot get to them. If you try to retrieve an existing http://mydomain.com/Web.config file, you'll be presented with an "Access denied" error message.&lt;br /&gt;    * IIS monitors the Web.config files for changes and caches the contents for performance reasons. There's no need to restart the Web server after you modify a Web.config file.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-5471653906080273605?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/5471653906080273605/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2010/03/aspnet-webconfig-file.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/5471653906080273605'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/5471653906080273605'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2010/03/aspnet-webconfig-file.html' title='ASP.NET Web.config File'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-1380682437878747789</id><published>2010-03-08T23:08:00.000-08:00</published><updated>2010-03-08T23:08:23.445-08:00</updated><title type='text'>Introduction to ADO.Net</title><content type='html'>In any .NET data access page, before you connect to a database, you first have to import all the necessary namespaces that will allow you to work with the objects required. As we're going to work with SQL Server, we'll first import the namespaces we need. Namespaces in .NET are simply a neat and orderly way of organizing objects, so that nothing becomes ambiguous.&lt;br /&gt;&lt;br /&gt;&lt;%@ Import Namespace="System" %&gt;&lt;br /&gt;&lt;%@ Import Namespace="System.Data" %&gt;&lt;br /&gt;&lt;%@ Import Namespace="System.Data.SqlClient" %&gt;&lt;br /&gt;&lt;br /&gt;Note: If we were using a database other than SQL, for instance, MS Access, we would then replace the SQLClient with OleDb. If we use Oracle, .NET v 1.1 provides the System.Data.OracleClient namespace, and for any ODBC data source it provides the System.Data.Odbc namespace. You'll find detailed information on all the available methods and objects we'll discuss in the .NET SDK Framework documentation.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Connection:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;After we import all the necessary namespaces, we're ready to connect to our database. Now, whether you implement the DataReader or Dataset, your initial database connection will still be as follows:&lt;br /&gt;&lt;br /&gt;SqlConnection objConnect = new SqlConnection (Your Connection String);&lt;br /&gt;&lt;br /&gt;objConnect.Open();&lt;br /&gt;&lt;br /&gt;Methods:&lt;br /&gt;&lt;br /&gt;.Open - Opens the connection to our database&lt;br /&gt;.Close - Closes the database connection &lt;br /&gt;.Dispose - Releases the resources on the connection object. Used to force garbage  collecting, ensuring no resources are being held after our connection is used.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;DataReader:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Used to read the data from the database table.The four Execute methods all pertain to an action performed by the Command object, wile the remaining methods are used to enhance the Command object's own functionality.&lt;br /&gt;&lt;br /&gt;. &lt;b&gt;ExecuteReader &lt;/b&gt;- Simply executes the SQL query against the database, using the Read() method to traverse through data, as illustrated below&lt;br /&gt;. &lt;b&gt;ExecuteNonQuery &lt;/b&gt;- Used whenever you work with SQL stored procedures with parameters, as illustrated in the Stored Procedures section below&lt;br /&gt;. &lt;b&gt;ExecuteScalar &lt;/b&gt;- Returns a lightning fast single value as an object from your database Ex. object val = Command.ExecuteScalar(); Then check if != null.&lt;br /&gt;. &lt;b&gt;ExecuteXmlReader &lt;/b&gt;- Executes the SQL query against SQL Server only, while returning an XmlReader object. See .NET documentation for more information.&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;&lt;br /&gt;SqlCommand objCommand = new SqlCommand(Sql String, objConnect);   &lt;br /&gt;SqlDataReader objDataReader = objCommand.ExecuteReader();&lt;br /&gt;while (objDataReader.Read() == true) &lt;br /&gt;{&lt;br /&gt; Response.Write (objDataReader[0].ToString() + "&lt;BR&gt;");  &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;b&gt;DataReader Methods:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;. Read - Moves the record pointer to the first row, which allows the data to be read by column name or index position. Can check for data existence with conditional, if (DataReader.Read() = true)&lt;br /&gt;. HasRows - New only with .NET v1.1. HasRows checks if any data exists, and is used instead of the Read method. Ex. if (DataReader.HasRows).&lt;br /&gt;. IsClosed - A method that can determine if the DataReader is closed. Ex. if (DataReader.IsClosed == false) &lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;Stored Procedures:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The Datareader itself, as with the DataSet, is more than capable of dealing with Stored Procedures; they offer plenty of performance advantages and the ability to consolidate many operations in one location. However, the Dataset's approach to Stored Procedures tends to become a little drawn-out, as it follows closely with the data manipulation model that the Dataset offers. When it comes to quick and straightforward Stored Procedure handling, the DataReader's Command Object methods are more than sufficient, as we'll see now.&lt;br /&gt;&lt;br /&gt;We begin by creating a trivial stored procedure that accepts one parameter - @txt, which is passed into my query&lt;br /&gt;&lt;br /&gt;CREATE PROCEDURE ShowSuppliers (  &lt;br /&gt;@txt varchar(50)  &lt;br /&gt;)  &lt;br /&gt;AS  &lt;br /&gt;Select CompanyName, City, Country from Suppliers Where    &lt;br /&gt;Country like "%" + @txt + "%"&lt;br /&gt;&lt;br /&gt;If you wanted to simply execute a Stored Procedure, pass it a value, and then read through that, how would you do it? Easy! Prior to calling the ExecuteReader method, replace the SQL String in the SqlCommand constructor with the name of the Stored Procedure, then specify to the Command Object's CommandType Property that you're working with a Stored Procedure. After you've done this, implement the Parameters collection (via the Param SqlParameter variable) to set up the value you wish to pass to your stored procedure, like so:&lt;br /&gt;&lt;br /&gt;SqlCommand objCommand = new SqlCommand("ShowSuppliers",  &lt;br /&gt;objConnect);  &lt;br /&gt;objCommand.CommandType = CommandType.StoredProcedure;  &lt;br /&gt; &lt;br /&gt;SqlDataReader objDataReader = objCommand.ExecuteReader  &lt;br /&gt;(CommandBehavior.CloseConnection);  &lt;br /&gt; &lt;br /&gt;SqlParameter Param = objCommand.Parameters.Add("@txt",    &lt;br /&gt;SqlDbType.VarChar, 50);  &lt;br /&gt;Param.Value = "US";  &lt;br /&gt; &lt;br /&gt;// ... Get Data&lt;br /&gt;&lt;br /&gt;Stored Procedures - and Alternative Method&lt;br /&gt;&lt;br /&gt;An alternative method of working with Stored Procedures within this context is the Command.ExecuteNonQuery() method. This is useful when working with more multifaceted Stored Procedures that have input, output and return values. Using them is not that much more complicated; simply implement the Parameters collection shown below, i.e. Param.Direction = ParameterDirection.Input or .OutPut or .ReturnValue; and apply the .Value =, whatever the value type:&lt;br /&gt;&lt;br /&gt;CREATE PROCEDURE ShowSuppliers (  &lt;br /&gt;@txt varchar(50),  &lt;br /&gt;@Name varchar (50) output,  &lt;br /&gt;@Company varchar (50) output,  &lt;br /&gt;@Country varchar (50) output  &lt;br /&gt;)  &lt;br /&gt;AS  &lt;br /&gt;Select @Name = ContactName, @Company = CompanyName,    &lt;br /&gt;@Country = Country from Suppliers Where Country like "%" + @txt + "%"  &lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;Here we've created a slightly more elaborate Stored Procedure to illustrate the ExecuteQuery method. As you can see, this not only contains our initial search word variable - @txt, but we could now obtain several output values.&lt;br /&gt;&lt;br /&gt;// ... Database Connection / Command here like above  &lt;br /&gt; &lt;br /&gt;SqlParameter Param = objCommand.Parameters.Add("@txt",    &lt;br /&gt;SqlDbType.VarChar, 50);  &lt;br /&gt;Param.Direction = ParameterDirection.Input;  &lt;br /&gt;Param.Value = "US";  &lt;br /&gt; &lt;br /&gt;Param = objCommand.Parameters.Add("@Name", SqlDbType.VarChar,50);  &lt;br /&gt;Param.Direction = ParameterDirection.Output;  &lt;br /&gt; &lt;br /&gt;Param = objCommand.Parameters.Add("@Company", SqlDbType.VarChar,50);  &lt;br /&gt;Param.Direction = ParameterDirection.Output;  &lt;br /&gt; &lt;br /&gt;Param = objCommand.Parameters.Add("@Country", SqlDbType.VarChar,50);  &lt;br /&gt;Param.Direction = ParameterDirection.Output;  &lt;br /&gt; &lt;br /&gt;objCommand.ExecuteNonQuery();  &lt;br /&gt; &lt;br /&gt;Response.Write (objCommand.Parameters["@Name"]  &lt;br /&gt;.Value.ToString() + "&lt;BR&gt;");  &lt;br /&gt;Response.Write (objCommand.Parameters["@Company"]  &lt;br /&gt;.Value.ToString() + "&lt;BR&gt;");  &lt;br /&gt;Response.Write (objCommand.Parameters["@Country"]  &lt;br /&gt;.Value.ToString() + "&lt;BR&gt;");&lt;br /&gt;&lt;br /&gt;The only thing here that's dissimilar from our last Sproc example is the fact that we've just added a new Parameter Direction to reflect the values we wish to retrieve. In turn, we Response.Write them in the way shown here.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;DataSet:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The DataSet can be thought of as an in-memory storage container for all your data. It allows us far more capability and power over the manipulation and presentation of our data, even extending to XML. Here, the DataAdapter acts as the intermediary object responsible for joining our database with our DataSet, as the Command Object is with the DataReader.&lt;br /&gt;&lt;br /&gt;When working with Datasets, we would use the DataAdapter to do the querying, and the Fill() method to populate our DataSet with results:&lt;br /&gt;&lt;br /&gt;SqlDataAdapter objDataAdapter = new SqlDataAdapter ("Select    &lt;br /&gt;CompanyName, ContactName, City, Country, Region from    &lt;br /&gt;Suppliers", objConnect);    &lt;br /&gt;   &lt;br /&gt;DataSet objDS = new DataSet();    &lt;br /&gt;   &lt;br /&gt;objDataAdapter.Fill (objDS);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Dataview:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;By using a DataView we can create different views on our Dataset's DataTable, which enables us to filter or sort the data. To do this, you'd assign your DataGrid's Datasource property to the DataView, then bind it.&lt;br /&gt;&lt;br /&gt;DataView objView = objDS.Tables[0].DefaultView;    &lt;br /&gt;   &lt;br /&gt;objView.RowFilter = "Country like '%US%'";&lt;br /&gt;&lt;br /&gt;or&lt;br /&gt;&lt;br /&gt;objView.Sort = "Country asc";    &lt;br /&gt;   &lt;br /&gt;MyDataGrid.DataSource = objView;    &lt;br /&gt;   &lt;br /&gt;MyDataGrid.DataBind();&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-1380682437878747789?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/1380682437878747789/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2010/03/introduction-to-adonet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/1380682437878747789'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/1380682437878747789'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2010/03/introduction-to-adonet.html' title='Introduction to ADO.Net'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-8533174872508848436</id><published>2010-02-16T10:02:00.000-08:00</published><updated>2010-02-16T10:02:04.321-08:00</updated><title type='text'>Application Life Cycle in General</title><content type='html'>1. User requests an application resource from the Web server:&lt;br /&gt;&lt;br /&gt;The life cycle of an ASP.NET application starts with a request sent by a browser to the Web server (for ASP.NET applications, typically IIS). ASP.NET is an ISAPI extension under the Web server. When a Web server receives a request, it examines the file-name extension of the requested file, determines which ISAPI extension should handle the request, and then passes the request to the appropriate ISAPI extension. ASP.NET handles file name extensions that have been mapped to it, such as .aspx, .ascx, .ashx, and .asmx. &lt;br /&gt;&lt;br /&gt;2. ASP.NET receives the first request for the application:&lt;br /&gt;&lt;br /&gt;When ASP.NET receives the first request for any resource in an application, a class named ApplicationManager creates an application domain. Application domains provide isolation between applications for global variables and allow each application to be unloaded separately. Within an application domain, an instance of the class named HostingEnvironment is created, which provides access to information about the application such as the name of the folder where the application is stored.&lt;br /&gt;&lt;br /&gt;3. ASP.NET core objects are created for each request:&lt;br /&gt;&lt;br /&gt;After the application domain has been created and the HostingEnvironment object instantiated, ASP.NET creates and initializes core objects such as HttpContext, HttpRequest, and HttpResponse. The HttpContext class contains objects that are specific to the current application request, such as the HttpRequest and HttpResponse objects. The HttpRequest object contains information about the current request, including cookies and browser information. The HttpResponse object contains the response that is sent to the client, including all rendered output and cookies.&lt;br /&gt;&lt;br /&gt;4. An HttpApplication object is assigned to the request:&lt;br /&gt;&lt;br /&gt;After all core application objects have been initialized, the application is started by creating an instance of the HttpApplication class. If the application has a Global.asax file, ASP.NET instead creates an instance of the Global.asax class that is derived from the HttpApplication class and uses the derived class to represent the application.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-8533174872508848436?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/8533174872508848436/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2010/02/application-life-cycle-in-general.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/8533174872508848436'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/8533174872508848436'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2010/02/application-life-cycle-in-general.html' title='Application Life Cycle in General'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-9046211454231570972</id><published>2010-02-16T09:23:00.001-08:00</published><updated>2010-02-16T09:32:03.752-08:00</updated><title type='text'>Asp.Net2.0 Page Life Cycle</title><content type='html'>When an ASP.NET page runs, the page goes through a life cycle in which it performs a series of processing steps. These include initialization, instantiating controls, restoring and maintaining state, running event handler code, and rendering.&lt;br /&gt;&lt;br /&gt;Page Events:&lt;br /&gt;&lt;br /&gt;PreInit :&lt;br /&gt;&lt;br /&gt;Use this event for the following:&lt;br /&gt;&lt;br /&gt;·Check the IsPostBack property to determine whether this is the first time the page is   being processed.&lt;br /&gt;·Create or re-create dynamic controls.· Set a master page dynamically.&lt;br /&gt;·Set the Theme property dynamically.&lt;br /&gt;·Read or set profile property values.&lt;br /&gt;&lt;br /&gt;Init :&lt;br /&gt;&lt;br /&gt;Raised after all controls have been initialized and any skin settings have been applied. Use this event to read or initialize control properties.&lt;br /&gt;&lt;br /&gt;Load :&lt;br /&gt;&lt;br /&gt;The Page calls the OnLoad event method on the Page, then recursively does the same for each child control, which does the same for each of its child controls until the page and all controls are loaded.Use the OnLoad event method to set properties in controls and establish database connections.&lt;br /&gt;&lt;br /&gt;PreRender :&lt;br /&gt;&lt;br /&gt;The PreRender event occurs for each control on the page. Use the event to make final changes to the contents of the page or its controls.&lt;br /&gt;&lt;br /&gt;Unload :&lt;br /&gt;&lt;br /&gt;This event occurs for each control and then for the page. In controls, use this event to do final cleanup for specific controls, such as closing control-specific database connections.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-9046211454231570972?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/9046211454231570972/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2010/02/aspnet20-page-life-cycle.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/9046211454231570972'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/9046211454231570972'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2010/02/aspnet20-page-life-cycle.html' title='Asp.Net2.0 Page Life Cycle'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-8392658869838638298</id><published>2009-11-22T04:28:00.000-08:00</published><updated>2009-11-22T04:54:39.588-08:00</updated><title type='text'>Asp.Net Security</title><content type='html'>The .Net provides two security mechanism for asp.net application&lt;br /&gt;&lt;br /&gt;1. Windows Authentication&lt;br /&gt;2. Form Authentication&lt;br /&gt;&lt;br /&gt;Before going to have look on above security types, we will look into some basic&lt;br /&gt;terms that we used during this topic,&lt;br /&gt;&lt;br /&gt;1. Authentication&lt;br /&gt;2. Authorisation&lt;br /&gt;&lt;br /&gt;Authentication : Validating User Credentials [User name &amp; Password]  &lt;br /&gt;Authorization : Determines whether authenticated user has the permission to access the requested resource.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Windows Authentication :&lt;br /&gt;&lt;br /&gt;When asp.net application configured with 'Windows Authentication', Then it relies on IIS to authenticate its Clients using authentication types supported by the IIS.&lt;br /&gt;&lt;br /&gt;After Successfully authenticating user, IIS passes 'Windows Token' represents the authenticated user to the Asp.Net worker process.&lt;br /&gt;&lt;br /&gt;IIS Authentication Modes:    &lt;br /&gt;&lt;br /&gt;1. Anonymous authentication&lt;br /&gt;2. Basic authentication&lt;br /&gt;3. Integrated Windows authentication&lt;br /&gt;&lt;br /&gt;Anonymous authentication :&lt;br /&gt;&lt;br /&gt;If you do not need to authenticate your clients then you can configure IIS to allow anonymous access. In this event, IIS creates a Windows token to represent all anonymous users with the same anonymous (or guest) account. The default anonymous account is IUSR_MACHINENAME.&lt;br /&gt;&lt;br /&gt;Basic authentication :&lt;br /&gt;&lt;br /&gt;Basic authentication requires the user to supply credentials in the form of a user name and password to prove their identity. &lt;br /&gt;&lt;br /&gt;Integrated Windows :&lt;br /&gt;&lt;br /&gt;Integrated Windows authentication (formerly called NTLM, and also known as Windows NT Challenge/Response authentication) uses either Kerberos v5 authentication or NTLM authentication, depending upon the client and server configuration.&lt;br /&gt;&lt;br /&gt;IF Your ASP.NET Web application is running under the NetworkService account or a custom domain account. If your application runs under a local account, such as the ASP.NET account on Windows 2000 Server, then NTLM authentication will be used. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Windows Authentication :&lt;br /&gt;&lt;br /&gt;The WindowsAuthenticationModule class is activated when the following element is in the Web.config file&lt;br /&gt;&lt;authentication mode="Windows" /&gt;&lt;br /&gt;&lt;br /&gt;The WindowsAuthenticationModule class is responsible for creating WindowsPrincipal and WindowsIdentity objects to represent the authenticated user, and for attaching these objects to the current Web request.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-8392658869838638298?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/8392658869838638298/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2009/11/aspnet-security.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/8392658869838638298'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/8392658869838638298'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2009/11/aspnet-security.html' title='Asp.Net Security'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-167749745186336504</id><published>2008-12-17T04:57:00.000-08:00</published><updated>2009-11-22T04:09:36.636-08:00</updated><title type='text'>Tracking code to my website</title><content type='html'>Please refer the following URL:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;http://www.google.com/support/googleanalytics/bin/answer.py?answer=55488&amp;topic=11126&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-167749745186336504?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/167749745186336504/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2008/12/tracking-code-to-my-website_17.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/167749745186336504'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/167749745186336504'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2008/12/tracking-code-to-my-website_17.html' title='Tracking code to my website'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-7959931003120459203</id><published>2008-12-17T04:45:00.000-08:00</published><updated>2008-12-17T04:48:18.484-08:00</updated><title type='text'>Send SMS from a trigger</title><content type='html'>-- given a sample table:&lt;br /&gt;CREATE TABLE [dbo].[TestTriggerSMS] &lt;br /&gt; (&lt;br /&gt;  [test_field] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL &lt;br /&gt; ) ON [PRIMARY]&lt;br /&gt;&lt;br /&gt;go&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;-- **************************************************&lt;br /&gt;create trigger tr_Update_TestTriggerSMS on [dbo].[TestTriggerSMS] &lt;br /&gt; for update&lt;br /&gt; as&lt;br /&gt; set nocount on&lt;br /&gt;&lt;br /&gt; declare @rows int&lt;br /&gt; select @rows = count(*) from inserted&lt;br /&gt;&lt;br /&gt; -- send notification if TestTriggerSMS table is being updated&lt;br /&gt;  &lt;br /&gt; if @rows=1 -- notification only if update 1 row&lt;br /&gt; begin &lt;br /&gt;  if update(test_field) -- notification only if update [test_field] field&lt;br /&gt;  begin&lt;br /&gt;   print ' [test_field] field updated'&lt;br /&gt;   declare @old_value varchar(50)&lt;br /&gt;    , @new_value varchar(50)&lt;br /&gt;&lt;br /&gt;   declare @tab char(1)&lt;br /&gt;   set @tab = char(9)&lt;br /&gt;&lt;br /&gt;   &lt;br /&gt;   declare @message varchar(555)&lt;br /&gt;&lt;br /&gt;   set @old_value = (select test_field from deleted)&lt;br /&gt;   set @new_value  = (select test_field from inserted)&lt;br /&gt;&lt;br /&gt;   set @message = 'TestTriggerSMS updated:' + char(13) + &lt;br /&gt;      'Old Value ' + @tab  +  @tab + '[' + @old_value + ']'+ char(13) +&lt;br /&gt;      'New Value ' + @tab  +  @tab + '[' + @new_value + ']'&lt;br /&gt;      &lt;br /&gt;   exec master.dbo.xp_sendmail @recipients = 'siccolo_mobile_management@yahoo.com'&lt;br /&gt;    , @message = @message&lt;br /&gt;    , @subject = 'TestTriggerSMS updated!'&lt;br /&gt;&lt;br /&gt;   -- send SMS to cell phone --&lt;br /&gt;   /*&lt;br /&gt;   Teleflip.com now provides SMS service. &lt;br /&gt;   To use teleflip just email the SMS message to the following email address: &lt;br /&gt;   &lt;10 digit cell number&gt;@teleflip.com&lt;br /&gt;    -- or --&lt;br /&gt;   T-Mobile: phonenumber@tmomail.net &lt;br /&gt;   Virgin Mobile: phonenumber@vmobl.com &lt;br /&gt;   Cingular: phonenumber@cingularme.com &lt;br /&gt;   Sprint: phonenumber@messaging.sprintpcs.com &lt;br /&gt;   Verizon: phonenumber@vtext.com &lt;br /&gt;   Nextel: phonenumber@messaging.nextel.com &lt;br /&gt;   &lt;br /&gt;   where phonenumber = your 10 digit phone number &lt;br /&gt;   */&lt;br /&gt;   exec master.dbo.xp_sendmail @recipients = '4108441212@cingularme.com'&lt;br /&gt;    , @message = @message&lt;br /&gt;    , @subject = 'TestTriggerSMS updated!'&lt;br /&gt;  end&lt;br /&gt; end&lt;br /&gt;&lt;br /&gt; set nocount off&lt;br /&gt;go&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-7959931003120459203?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/7959931003120459203/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2008/12/send-sms-from-trigger.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/7959931003120459203'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/7959931003120459203'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2008/12/send-sms-from-trigger.html' title='Send SMS from a trigger'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-969369647355968822</id><published>2008-12-11T23:05:00.000-08:00</published><updated>2008-12-11T23:16:56.702-08:00</updated><title type='text'>JavaScript Events</title><content type='html'>&lt;span style="font-weight:bold;"&gt;Form Events&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;blur - The input focus was lost. &lt;br /&gt;change - An element lost the focus since it was changed. &lt;br /&gt;focus - The input focus was obtained. &lt;br /&gt;reset - The user reset the object, usually a form. &lt;br /&gt;select - Some text is selected &lt;br /&gt;submit - The user submitted an object, usually a form&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Image Events&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;abort - A user action caused an abort. &lt;br /&gt;error - An error occurred. &lt;br /&gt;load - The object was loaded. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;Image Map Events&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;mouseOut - The mouse is moved from on top a link. &lt;br /&gt;mouseOver - The mouse is moved over a link. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Link Events&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;click - An object was clicked. &lt;br /&gt;mouseOut - The mouse is moved from on top a link. &lt;br /&gt;mouseOver - The mouse is moved over a link. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Window Events&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;blur - The input focus was lost. &lt;br /&gt;error - An error occurred. &lt;br /&gt;focus - The input focus was obtained. &lt;br /&gt;load - The object was loaded. &lt;br /&gt;unload - The object was exited.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-969369647355968822?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/969369647355968822/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2008/12/javascript-events.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/969369647355968822'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/969369647355968822'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2008/12/javascript-events.html' title='JavaScript Events'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-369103808057333136</id><published>2008-12-11T22:50:00.000-08:00</published><updated>2008-12-11T23:04:47.650-08:00</updated><title type='text'>Asynchronous Calls in asp.net2.0</title><content type='html'>.Net Framework 2.0 makes life so easy with asynchronous calls from pages. I remember in asp.net1.x we had to do so much to achieve the same behaviour, but we are lucky that in asp.net2.0 its very easy.&lt;br /&gt;Again there are more than one ways to implement asynchronous calls in asp.net2.0 and you may be asking which pattern to use. &lt;br /&gt;The first way is to use the AddOnPreRenderCompleteAsync&lt;br /&gt;AddOnPreRenderCompleteAsync (&lt;br /&gt;    new BeginEventHandler(BeginAsyncMethod),&lt;br /&gt;    new EndEventHandler (EndAsyncMethod)&lt;br /&gt;);&lt;br /&gt;&lt;br /&gt;The second way is to use the PageAsyncTask and RegisterAsyncTask&lt;br /&gt;PageAsyncTask task = new PageAsyncTask( &lt;br /&gt;new BeginEventHandler(BeginAsyncMethod), &lt;br /&gt;new EndEventHandler(EndAsyncMethod), &lt;br /&gt;new EndEventHandler(TimeoutAsyncMethod), null &lt;br /&gt;); &lt;br /&gt;&lt;br /&gt; RegisterAsyncTask(task);&lt;br /&gt;&lt;br /&gt;The second way is preferrably better as it has the following advantages over the first way.&lt;br /&gt;• RegisterAsyncTask also take an additional parameter for timeout. &lt;br /&gt;• More than one RegisterAsyncTask can be called in one Request. &lt;br /&gt;• The fourth parameter of RegisterAsyncTask can take state of the Begin Method. &lt;br /&gt;• To the End the Timeout Method RegisterAsynTask gives you handy objects (ie HttpContext.Current, impersonation and culture).&lt;br /&gt;&lt;br /&gt;Remember to put Async="true" attribute in the @ Page directive for any of the preferred methods mentioned above.&lt;br /&gt;Also for Webservices we can use this following pattern:&lt;br /&gt;theproxy.MyMethodCompleted += new MyMethodCompletedEventHandler (OnMyMethodCompleted);&lt;br /&gt;theproxy.MyMethodAsync (...);&lt;br /&gt;&lt;br /&gt;void OnMyMethodCompleted (Object source, MyMethodCompletedEventArgs e)&lt;br /&gt;{&lt;br /&gt;    // This is called when MyMethod completes&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-369103808057333136?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/369103808057333136/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2008/12/asynchronous-calls-in-aspnet20.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/369103808057333136'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/369103808057333136'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2008/12/asynchronous-calls-in-aspnet20.html' title='Asynchronous Calls in asp.net2.0'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6802100233572382458.post-4698684280870837475</id><published>2008-12-11T22:31:00.000-08:00</published><updated>2008-12-11T22:50:30.769-08:00</updated><title type='text'>Tips to improve Performance of Web Application</title><content type='html'>&lt;span style="font-weight: bold;"&gt;In Web.config&lt;br /&gt;&lt;/span&gt;&lt;p&gt;1. Turn off Tracing unless until required. &lt;/p&gt; &lt;p&gt;&lt;trace enabled="false" pageoutput="false" tracemode="SortByTime" localonly="true"&gt; &lt;/trace&gt;&lt;/p&gt; &lt;p&gt;2. Turn off session state in web.config file or at least for a page if there  is no sessions. &lt;/p&gt; &lt;p&gt;3.  set debug=false &lt;/p&gt; &lt;p&gt;&lt;compilation defaultlanguage="c#" debug="false"&gt; &lt;/compilation&gt;&lt;/p&gt; &lt;p&gt;4. Increase the Pool "Packet size" for transferring large blob or image  fields&lt;br /&gt;&lt;/p&gt;&lt;p&gt;5. &lt;place st="on"&gt;&lt;placename st="on"&gt;Disable&lt;/placename&gt; &lt;placename st="on"&gt;View&lt;/placename&gt; &lt;placetype st="on"&gt;State&lt;/placetype&gt;&lt;/place&gt; of a Page or Datagrid if possible.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;6. Use Response.Redirect (".aspx",false) instead of response.redirect(".aspx"). It  &lt;/p&gt; &lt;p&gt;     Reduces CLR Exceptions count. &lt;/p&gt;&lt;p&gt;7. String Builder in place of string when ever needed&lt;br /&gt;&lt;/p&gt;&lt;p&gt;8. Avoid Throwing Exceptions. It is very expensive.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;9. Avoid Recursive Functions / Nested Loops&lt;br /&gt;&lt;/p&gt;&lt;p&gt;10. Enable Option Strict and Option Explicit for your pages.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;11.  Avoid unnecessary round trips to the server&lt;br /&gt;&lt;/p&gt;&lt;p&gt;12. Precompiling pages and disabling AutoEventWireup&lt;br /&gt;&lt;/p&gt;&lt;p&gt;13.  Use "For each" Instead of For.&lt;/p&gt;&lt;p&gt;14. Explicitly Close Connections&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6802100233572382458-4698684280870837475?l=ngpuranik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ngpuranik.blogspot.com/feeds/4698684280870837475/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ngpuranik.blogspot.com/2008/12/tips-to-improve-performance-of-web.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/4698684280870837475'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6802100233572382458/posts/default/4698684280870837475'/><link rel='alternate' type='text/html' href='http://ngpuranik.blogspot.com/2008/12/tips-to-improve-performance-of-web.html' title='Tips to improve Performance of Web Application'/><author><name>Narsimha Puranik</name><uri>http://www.blogger.com/profile/13320965235178569018</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/-apDuR-uBkwA/TyrafSJjlVI/AAAAAAAAAM8/Th28Qqd8kec/s220/IMG051.jpg'/></author><thr:total>0</thr:total></entry></feed>
