Tuesday, December 21, 2010

DotNet Frequently Asked Questions

<> What is tooltip class? How it was implemented?
ToolTip Class is used to create a custome tooltip message for the any controls and associated with controls.
ToolTip objPictureBox=new ToolTip();
objPictureBox.Text="This is picturebox control";
PictureBox1.Controls.Add(objPictureBox);

<> Describe ASP .Net Page Life Cycle?
Set of subprograms that are executed towards each time of web page processing
are called page life cycle events
Page Preinit
This will be executed before memory initialization for web page [before
constructing web page]Attaching theme master page dynamically to webpage is possible using preinit
event proc
Page init
This will be executed when memory is initialized for webpage
Page load
This will be executed when submitted data and controls are loaded
Database connectivity reading submitted data can be placed within pageload
PagePrerender
This will be executed before rendering html content from server side control
Control behaviour can be changed b4 producing client side control
Page Unload
This will be executed once memory is released for webpage
Closing database connection

<> What is the difference between Dataset.clone() and Dataset.copy()?
Dataset.clone(): Copies the structure of the dataset including all schemas relations and constraints. Does not copy any data.
Dataset.copy(): Copies both the structure and data.

<> What is the difference between EVENTS and FUNCTIONS?
Event represents an action that is done to an object whereas Function represents an action that the object itself is doing.

<> how do you differentiate managed code and unmanaged code?
The code which is under control of CLR (Common Language Runtime) is called managed code.
The code which takes Operating System help while execution is called unmanaged code.

<> What is the use of AutoWireup in asp.net
The ASP.NET page framework also supports an automatic way to associate page events and methods. If the AutoEventWireup attribute of the Page directive is set to true (or if it is missing, since by default it is true), the page framework calls page events automatically, specifically the Page_Init and Page_Load methods. In that case, no explicit Handles clause or delegate is needed.
The disadvantage of the AutoEventWireup attribute is that it requires that the page event handlers have specific, predictable names. This limits your flexibility in how you name your event handlers. Therefore, in Visual Studio, the AutoEventWireup attribute is set to false by default and the designer generates explicit code to bind page events to methods.
If you do set AutoEventWireup to true, Visual Studio will generate code to bind the events and the page framework will automatically call events based on their names. This can result in the same event code being called twice when the page runs. As a consequence, you should always leave AutoEventWireup set to false when working in Visual Studio.

<> What is Query String?
Query String is the part of a URL that contains data to be passed to web pages. Query string is a client side state management technique. URL is followed by Querystring separated by "?".
Using Query string we can pass small values in plain text format (by default) from one page to another. We can't pass huge chunk of data through query string due to the fact that many browsers limit the length of URL to 2083 characters for IE.
Basically this value is passed as follows..
This hyper link called the page1.aspx page with the querystring id with value 1.
It is a very good way the passing value from one page to another.
In the page1.aspx we can get these values as:
string value1=Request.QueryString( id );
Now the value1 will have the value=1

<> What is view state and how it is maintained?
View state allows the state of objects to be stored in a hidden field on the page.it is transported to the client and back to the server and is not stored on the server or any other external source.view state is used to retain the state of serverside objects between post backs.

<> What is the maximum length of textbox?
The Maximum Length a Textbox can hold is 65535

<> What is the use of Master Page?
Master pages allow you to create a consistent look and behavior for all the pages (or group of pages) in your web application.
A master page provides a template for other pages, with shared layout and functionality. The master page defines placeholders for the content, which can be overridden by content pages. The output result is a combination of the master page and the content page.
The content pages contains the content you want to display.
When users request the content page, ASP.NET merges the pages to produce output that combines the layout of the master page with the content of the content page.

<> What is the difference between VB and C#.Net?
As far as .net framework concern all the programming languages are pretty much similar. The only difference is the way they support to the programmers.In short syntax, structure and declaration are only paramount.
If we observe the below two fragment code blocks...
In vb.net
For i as Integer =0 to n
{
string kranthi+=i.ToString();
}
In C#.Net
For(int i=0;i less than n;i increment)(note : Here am using words rather than symbols.because of blogger doesn't allow to place some symbols over here )
{
string kranthi+=i;
}

We can observe two major differences in the above two code fragments.

one is declaration in vb is like For i as Integer.In case of c# (int i=xxxxx)..this is pretty much similar to c-family language. In fact the programmer with previous knowledge of c-like languages .. he/she can easily to understand c# than vb.

the second one is in c# integer value can automatically convert to string when you concatenate with + operator. where as in vb we have to explicitly convert to string when you concatenate with + operator.

More over c# is case sensitive where as vb is not case sensitive..
and still some minor differences are there in both.. for more details click here

<> Validating User Input?
The purpose of the validation controls is to validate the user input. Asp.net provides the developer with different types of validation controls. One most important point to note is that the validation is done on the client side as well as on the server side. You can always turn the validation on the client side off using the enable client side property to false. Lets see the difference between the client side validation and the server side validation.

Client Side Validation
Client side validations taken place at client browser. it does not require a postback operation and provides fast responses to the user. However, because the validation code is outside the Web Server, it might be possible for the client to spoof the Web Server with invalid data. The addition to this, client-side validation requires the client(browser) to be capable of running scripts. That might be an issue with old browsers..

Server Side Validation

When the validation code is placed the server side, the process of validation might be slow because a form might involve multiple roundtrips to the Web Server before all the data is validated and Server-side validation works well with all browsers.

For any important(sensitive) data it is not safe then to do at server side only otherwise go for client side validations.

<> Difference between java script validations and asp.net validation controls
JavaScript function can be used only at the client side but the asp.net validation controls can be used to validate at the client side as well as at the server side.
So if you just want to validate at the client site and want a very fast validation use java script. otherwise use asp.net validation control as validating both the sites is always best.


<> Difference between javascript, Jquery and AJAX
Javascript is a scripting language.it was developed for interacting web pages. and we can directly embed javascript code in HTML Pages.
Jquery is a light weight open source javascript libraries(Around 50 kb in size) its was also designed for the same purpose. but the major benefit of jquery is allow user to find and manipulate HTML elements with minimum lines of code. For example some times a common task of 10 lines of code with traditional javascript can be accomplished in jquery with a one line of code.
Finally what i mean to say is Jquery is designed for interacting with web pages with more efficient and simple than Javascript.
Now move to ajax..
Ajax is a set of functions of language javascript. Its a Build one and every control in ajaxcontroltoolkit was designed for specific purpose.
But Jquery is a set of functions in javascript.it's not a build one.we have to include script tag for code blocks.


<> Difference between late binding & early binding.

Dim MyVariable as Object
Above variable is said to be "late bound" because the software doesn't really know what it is until runtime when it's actually used for something. Here's an example of late binding:
Dim MyVariable As Object
MyVariable = "About Visual Basic"
Debug.WriteLine("The variable data type is: " & MyVariable.GetType.ToString)
MyVariable = #6/30/2006#
Debug.WriteLine("The variable data type is: " & MyVariable.GetType.ToString)
In this case, MyVariable is simply converted to whatever data type is necessary. When the code is run, the result in the Immediate window of VBE is:
The variable data type is: System.String
The variable data type is: System.DateTime
Whenever possible, you should use "early binding" and declare variables as a specific type. There are basically three reasons:
1) It makes your program run faster since code to convert to the actual type isn't necessary.
2) The compiler can help find errors that might otherwise cause a runtime program crash.
3) Intellisense code completion and Dynamic Helponly works with early bound variables.
  method overloading is an example of compile time/static polymorphism because method binding b/w method call and method definition happens at compile time. we can't declare same methods with same signature in a class. it occurs error at compile time. this also called early binding
  method overriding  is an example of run time/dynamic polymorphism because method binding b/w method call and method defination happens at run time. this also called late binding what is CLR? CLR is a common language run time for Microsoft .Net framework. it's responsible for manage the execution process of .net source code. its simply converts source code to IL code (MSIL). it's a platform independent code. CLR uses JIT compiler to convert IL code to native Code Of OS. it also manage exception handling, garbage collection and type safe.