Tuesday, April 17, 2012

New Features in Dotnet 4.0

C# 4.0 :
1.Named and optional parameter
2.Dynamic support.
3.Variance(Invariant,Covariant,Contravariant).

Asp.net :4.0:
1.Search Engine Optimization
Meta Description
Web Form Routing
Permanent Redirection
2.Setting Client Ids
3.Persisting row selection in Data Controls.
4.Enabling Viewstate for Page level and control level.
5.Extensible outout caching.
6.Enum- Has Flag
7.Managed Extensible Framework or MEF.
8.Server Control Enhancement
RadioButtonList and Checkbox List
Enhancement in List view control
CSS Friendly Menu Control


Visual studio 4.0:

1.Multi targeting
2.Different Version of Integrated Web Server
3.Code Snippets for Web designer
4.Java script intellesence
5.Project Templates
6.Publish a web application

Wednesday, July 14, 2010

New Features in ASP.Net 4.0 - PART 1

Search Engine Optimization:

1.Meta data Keyword and Descrption :
Adding MetaKeyword and MetaDescription Using Page object.Meta keywords and description are most important components of a page when we want to make it search engine friendly. Every search engine will look for these tags to know more information of the page contents. ASP.Net 2.0 introduced a new feature where one can add these tags from the code behind using HtmlMeta class. It would have been better if we are able to do this through Page directive (Page class). ASP.Net 4.0 added 2 new properties on the Page object to let you define the Meta keywords and Description.

Refer the code below,
protected void Page_Load(object sender, EventArgs e){
Page.MetaKeywords = "asp.net,C#";
Page.MetaDescription = "This is an asp.net site that hosts asp.net tutorials.";
}
OR
<%@ Page Language="C#" AutoEventWireup="true" MetaKeywords="asp.net,C#" MetaDescription="This is an asp.net site that hosts asp.net tutorials" CodeFile="Default.aspx.cs" Inherits="_Default" %>
The above code will add the meta tags in the output html.

Note
We can still do this in earlier version by defining a BasePage class. 
Enabling Viewstate for Page level and control level: 
    ViewState is one of the important factors if we start looking at improving the performance our asp.net site. Till ASP.Net 3.x, we have EnableViewState property both at Page level and server control level to control the view state. Disabling the ViewState at page level will disable the viewstate to all the page controls. In order to improve the performance, one need to switch off the viewstate for individual control for which saving the viewstate is not necessary and hence disabling viewstate at page level is not a suitable option. To overcome this difficulty, asp.net 4.0 added a new property to Page object and controls called ViewStateMode.
This property can take 3 values: 
  1. Enabled :This value will enable the view state. This is the default value for the Page object. 
  2. Disabled : This value will disable the viewstate. 
  3. Inherit : This value will make the control to inherit the setting of the parent. This is the default value for a control.
With this property, we can disable the viewstate for the page and enable it for the control if only required.
Consider the following code,
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ViewStateTest.aspx.cs" ViewStateMode="Disabled" Inherits="ViewStateTest" %>


ViewStateMode="Enabled"
Text="Default Text"
CodeBehind
protected void Page_Load(object sender, EventArgs e){
if (!IsPostBack){
Label1.Text = "Text Assigned in CodeBehind";
Label2.Text = "Text Assigned in CodeBehind";
}}
When the page executed we will get the following output,
Text Assigned in CodeBehind
Text Assigned in CodeBehind
When the button is clicked,
Text Assigned in CodeBehind
Default Text
Since, the viewstate is disabled at page level (Page object) and the viewstate is enabled for “Label1” we will get the above output on Button click. Please note that if we have not set the value, the default will be “inherit” (for Label2).
Note
If we disabled the viewstate through EnableViewState property, setting any values for ViewStateMode property will make no impact.

Tuesday, June 15, 2010

Reset the identity on Table

dbcc checkident (table_1, reseed, 0)

Monday, May 3, 2010

How Web service create Proxy and dll Using WSDL?


In this  post  we are going to understand  how create web service proxy and consume service into console application(Client).
Building Web Service Clients using the .NET Framework:
            Clients communicate with Web Services using standard web protocols, using XML-encoded messages to send and receive messages between themselves. This makes it possible for client applications running on any platform to access web services as long as they use standard web protocols, and understand the XML-encoded messages. 
          There are three protocols that web clients can use to communicate with web services namely,
  1. HTTP GET
  2. HTTP POST 
  3. SOAP.
          The various steps that are involved in creating a Web Service Client using C# and the .NET Framework are as follows:
  1. Generate a Proxy for the Web Service
  2. Compile the Proxy as a DLL library
  3. Create a Visual C# - Console Application Project
1. Generate a Proxy class for the Web Service
.NET SDK provide WSDL.exe utility to generate proxy source code for an existing web service.WSDL.exe utility take a WSDL file as input to generate proxy source code.
we can generate proxy source code for the actual web service as shown below:
1.Go to .NET Command prompt
2.Type following command to create proxy source code
WSDL http://hostServer/WebserviceRoot/WebServiceName.asmx?WSDL
(Created new proxy class file and it's located into default .NET command prompt folder)
 OR
WSDL /out:myProxyClass.cs http://hostServer/WebserviceRoot/WebServiceName.asmx?WSDL
if we want to create proxy class as specific user defined name, we can specify class name in next to out keyword.

2. Compile the Proxy class as a DLL Library
          We can compile the C# generated proxy class file into a dynamic link library (DLL) and then add a reference to this DLL to any project we want to consume service.
3. Create a Visual C# - Console application
  1. Create a new Visual C# console application in order to consume web service and add a reference to the already created DLL(based on point no.1 & 2).
  2. We create an instance of the proxy class and call functionality wherever required.
  3. Build the project file and run the client.

Thursday, April 29, 2010

Difference Between URI and URL

URI- Uniform resource Identifier is a superset of URL and URN
e.g.- products/books/detail.html
    It is not a URL because it does not specify how to retrieve the resource.

URL – http://www.xyz.com/products/books/detail.html
is a URL because it specifies how to retrieve the resource

URN- e.g. ISBN:1-9211009-59 is a URN because it uniquely identifies this book.

We can get this to use following code :

System.out.println(“URI : “+ httpRequestObj.getRequestURI());
System.out.println(“URL : “+ httpRequestObj.getRequestURL());

IN vs Exists

IN:

Returns true if a specified value matches any value in a subquery or a list.

Exists:

Returns true if a subquery contains any rows.

What is INDEX ?

Index is created on existing table to retrieve row quickly.

For e.g. There are thousands of records in a table, retrieving information will take long time. Therefore Index has created on column which are accessed frequently. So that the information able to retrieve quickly. Index can be created on a single column or group of columns. When index is created, it first sort the data and then it assigns RowId for each row.

Syntax :
CREATE INDEX index_name
ON table_name (column_name1,column_name2...);

There are two type of index available in sql namely like
1.Clustered Indexes
2.Non clustered Index

Clustered Index :
            It can be created using "create index ..." syntax.
Non Clustered Indexes :
            They are created when a column is explicitly defined with PRIMARY KEY, UNIQUE KEY Constraint which is not based on sorted record but on a bookmark.

Note:
1) Even though sql indexes are created to access the rows in the table quickly, they slow down DML operations like INSERT, UPDATE, DELETE on the table, because the indexes and tables both are updated along when a DML operation is performed. So use indexes only on columns which are used to search the table frequently.
2) If we have less data, not required to create indexes.
3) In oracle database you can define up to sixteen (16) columns in an INDEX.