Posts

Showing posts from May, 2012

ViewStateMode in ASP.Net 4.0

ViewStateMode in ASP.Net 4.0 When asp.net introduced the concept of viewstate, it changed the way how developers maintain the state for the controls in a web page. Until then to keep the track of the control(in classic asp), it was the developer responsibility to manually assign the posted content before rendering the control again. Viewstate made allowed the developer to do it with ease. The developers are not bothered about how controls keep there state on post back. Viewstate is rendered to the browser as a hidden variable __viewstate. Since viewstate stores the values of all controls, as the number of controls in the page increases, the content of viewstate grows large. It causes some websites to load slowly. As developers we need viewstate, but actually we do not want this for all the controls in the page. Till asp.net 3.5, if viewstate is disabled from web.config (using .. ), then you can not enable it from the control level/page level. Both <%@ Page En

Method Overriding in C#.NET

Method Overriding in C#.NET Creating a method in derived class with same signature as a method in base class is called as method overriding. Same signature means methods must have same name, same number of arguments and same type of arguments. Method overriding is possible only in derived classes, but not within the same class. When derived class needs a method with same signature as in base class, but wants to execute different code than provided by base class then method overriding will be used. To allow the derived class to override a method of the base class, C# provides two options, virtual methods and abstract methods.

Improvements in C# 4.0

Improvements in C# 4.0 C# in .NET Framework 4.0 has some more things to offer. These are: Dynamic lookup Named Optional parameters Dynamic Lookup There is a new static type named dynamic . We can use it as object of any type. If there is any error on its usage, we would get it on runtime only. For example: dynamic integerValue = 1 ; dynamic stringValue = " a string" ; dynamic Result = integerValue + stringValue; Output of this would be: 1 a string . But, if you change the last line to: dynamic Result = integerValue & stringValue; You will not get any compilation error, but the following error on runtime: Operator '&' cannot be applied to operands of type 'int' and 'string' Optional Parameters To implement optional parameters, we used to create overloaded functions before ASP.NET 4, but now, optional parameters are no more a restriction in C#. Like VB, optional parameters must be mentioned last. For exampl

Dot Net Interview question by Shivprasad Koirala

Dot Net Interview question by Shivprasad Koirala

C# FAQ: abstract class & interface , private constructor

What is abstract class ? Abstract class is a base class or a parent class. Abstract classes can  have empty abstract methods or it can have implemented methods which can be overridden by child classes. The next question i expected was on interfaces and yes there it comes. What are interfaces? Interface is a contract class with empty methods , properties and functions. Any class which implements the interface has to compulsory implement all the empty methods , functions and properties of the interface. Now the 1000% sure question was bound to come difference between them... What's the difference between abstract class and interface? There are many differences, below are some key two differences :- Abstract class are base class or parent class while interfaces are contracts. Abstract class can have some implemented methods and functions while interfaces methods and functions are completely empty. Abstract classes are inherited while interfaces are implemente

Basic Concepts of OOPs in .Net

Introduction .NET is fully object oriented platform that allow languages to take full adv antage of these OO features. The features include: Namespace Classes Abstract Encapsulation Overloading New. Overriding Interfaces Polymorphism Let’s take a quick look at what each of this term means. Namespace Even though namespace is not really an OOPs feature, .NET use it extensively. Namespace is nothing but a logical container for various classes. Under given namespace class names must be unique. Namespace server two purposes – they provide logical organization of classes and they also avoid ambiguity. Classes Class is nothing but a template or blue-print for an entity. For example you may have a class that represents real life entity – Employee. The class will provide properties (Name, Age…) as well as actions (CalculateSalary, GoOnLeave…) of the entity. Objects Instances of classes are called as objects.

SQL Tuning or SQL Optimization

Sql Statements are used to retrieve data from the database. We can get same results by writing different sql queries. But use of the best query is important when performance is considered. So you need to sql query tuning based on the requirement. Here is the list of queries which we use reqularly and how these sql queries can be optimized for better performance. SQL Tuning/SQL Optimization Techniques: 1) The sql query becomes faster if you use the actual columns names in SELECT statement instead of than '*'. For Example: Write the query as SELECT id, first_name, last_name, age, subject FROM student_details; Instead of: SELECT * FROM student_details; 2) HAVING clause is used to filter the rows after all the rows are selected. It is just like a filter. Do not use HAVING clause for any other purposes. For Example: Write the query as SELECT subject, count(subject) FROM student_details WHERE subject != 'Science' AND subject != 'Maths'

page events

Image
  Page Event PreInit Raised after the start stage is complete and before the initialization stage begins. Use this event for the following: Check the IsPostBack property to determine whether this is the first time the page is being processed. The IsCallback and IsCrossPagePostBack properties have also been set at this time. Create or re-create dynamic controls. Set a master page dynamically. Set the Theme property dynamically. Read or set profile property values. Note If the request is a postback, the values of the controls have not yet been restored from view state. If you set a control property at this stage, i
How IIS processes ASP.NET request Before understanding the full flow, we have to go through following concepts: IIS: IIS (Internet Information Server) is one of the most powerful web servers from Microsoft that is used to host your ASP.NET Web application. IIS has it’s own ASP.NET Process Engine  to handle the ASP.NET request. So, when a request comes from client to server, IIS takes that request and  process it and send response back to clients. Worker Porcess (w3wp.exe): Worker Process (w3wp.exe) runs the ASP.Net application in IIS. This process is responsible to manage all the request and response that are coming from client system. In short, Worker process is the heart of ASP.NET Web Application which runs on IIS. Application Pool: Application pool is the container of worker process. Application pools is used to separate the sets of IIS worker processes that share the same configuration. This makes sure that a particular web application doesn