Friday, 27 May 2016

. NET FRAMEWORK

The  .Net framework is the platform which is used to create the environment to run and execute the manged code.
The .Net framework contains CLR (Common language Runtime),CTS and CLS(Common language specification) which help to create the Suitable environment for managed code execution.The managed code like C# goes through many phase before it convert to the  machine language. When we compile the C# code, then Compiler convert this code to MSIL (Machine Intermediate language) not to the machine language, this MSIL is  OS and Hardware independent. After creation of MSIL, the CLR comes in picture CLR call the JIT (Just in time compiler) to convert the MSIL to the Machine code. It convert the MSIL to the machine code as required demand basis,  means, when that particular code required, then  only that code converted to the Machine code not the complete code.

Ther are two different type of Language in .net framework Managed code and Unmanaged code.
The code which obey all the rule of CTS and CLS then it is called managed code 
.Net framework :=> A programing infrastructure created by microsoft for building deploying and running application and services that use .net technology.

The .net technology contain three main parts
1)CLR
2)CTS
3)CLS

This is the architecture of the .Net framework, where as CLR also has some internal architecure


There is the Architecture of CLR: The CLR contain  GC and code manager, The Garbage collector play important role in allocating and deallocating of memory
Here I am going to show how the  code execution can take place and what  are all the phase of execution.

Wednesday, 25 May 2016

C# language basics

The language is generally used to communicate with one another, or it used to express their feelings. If we people want to express their feeling then we need some language , So that communication should be fluent and easy.
Same thing happen with Computer also it required one language to communicate like C and C#.
So we can say that C# is computer language, which is used to communicate with computer.
I want to tell you a story about a man who went to USA, He know some what english but not too good in english. So he always tarvel with dictionary , and use this dictionary when  he encounter with complex and complicated words.

Same thing happen with  compiler, Compiler use dictionary to resolve his complex and complicated words.
In C# language compiler use the dictionary  by refering USING Syntax.

I am starting with simple C# program (to print hello Tutorial)

First Demo Class program

 As we go through this code we observe lot of thing like System Console and Writeline and Readkey etc.

Here System is the namespace where as Console is the Static class,which  is present in the System namespace. So by the help of USING I am going to import this on our program.

NameSpace is the container which contain the class ,It used to avoid name conflict with another same name  class which is  present in the assembly.

C# is the pure object oriented programing language, so every thing present inside the Class.

Main is the entry point of the  program execution, So operating system start the execution of program from Main.

We are making Main as static so that it is the property of class  not object hence we donot require any object to call the Main method,operating System use the  Program class to call the Static Main method.

Console is the Static class, hence all the member of this class is by default static.WriteLine and Readkey are the static method, so we call this method by the help of Console class , we donot required any  object to call this method.

The Argument present in the Main are optional if you want you can remove this.
The Console.WriteLine are used to print the content on to the console.Where as Console.ReadKey are used to get data from the console.

The console is anything through which you are going to communicate with  your computer.Like Keybord and Monitor(VDU) etc.

This is the first tutorial through which you learn  to write the Hello world on console Application

Wednesday, 27 April 2016

Update with Update Panel

This tutorial is dedicated to  Update panel where we learn a lot of things . This control is used to perform Asynchronous  communication with a server.Generally the Update panel called Container control.

As we all know that, the Http is stateless protocol, It means each time  when a request goes to the server,Server create the complete  page from starting and then it create a complete control (Create object of control for the page) and then populate the page with these controls.


So each time when we click the button, server has to do a lot of things. and so it takes lots of time.so  creation of complete page ,the user experience flickering effect on web page.


To remove this effect from web page we have to use Partial page updates, or update panel,


Update panel: The update panel is asp control which is used to perform the partial page refresh or partial page update, it is used to perform the asynchronous communication to the server.


To use update panel we have to use script manager,

The Script manager perform mainly three task
1.Manage Ajax script library and script file
2.Help to perform the partial page rendering.
3.Help to create the client proxy class for web services
If we want to use the Ajax control like  update panel we have to use script manager, If we will not use the script manager then it will generate run time exception

Because there is nothing which registered Ajax update panel.So remember please use script manager before using any Ajax control tool.


 Let us take  some simple example of update panel, 

We have one web page where we do not have any  update panel, and it contain three Gridview and two button, When we click the button, Then complete request goes to the server and  hence complete web page and web  control were create.So it has to take some time to create the web page and  web control and then  place thses control onto the web page.

But If we have  update panel around each grid view and then if we click the button, then only that grid view data update not complete web page data.



Exactly the update panel do not do any magic to perform this things but, by the help of browser, it will update only specific web part not complete web page 


How Exactly Ajax Update panel or another Ajax control works.


Before understanding about AJAX control  we have to understand AJAX , The AJAX is Asynchronous Javascript and XML,  The Ajax used XmlHTTP request to perform the Asynchronous or Synchronous request.

Whenever there is request to server by the help of Ajax then we have to perform, the following task
1.Create the XMLHttpRequest
Then the request goes to the server and Server , And in server, the PHP or asp are used to get the data from  Database .Data are  converted onto JSON and  XML , then it send the JSON,XML to the Browser, the browser update only required part not complete page. Hence complete page fluctuation should not be there.




  

There is best example of Update panel, where I have two label and two button control,  part 1  where date is today date and time. part 2 where date is  next year date and time. If we click the  part1 getdate button , then Both the date change  (On click event I have written to get current time and Date, So both the label change and complete  page will fluctuate.)
But if we want to update only part1 and not part2 then we have to use  update panel which update individual part of the page  not complete page.
So we  have to put the two update panel  one around the first part and one around the second part.
to remove the complete page fluctuation .
Note:

An asynchronous postback behaves much like a synchronous postback. All the server page life-cycle events occur, and view state and form data are preserved. However, in the rendering phase, only the contents of the UpdatePanel control are sent to the browser. The rest of the page remains unchanged.

This is the most important concept in Asynchronous concept that only specific part are  update or refreshed, But behind the scene the whole page life cycle execute but,only specific part send to the browser . And browser refresh only that part not complete page..
But if we do not want to perform the Async call back then  we have to make enable call back =false to the  Script manager control.




Nesting Update Panel: we  can able to nest the Update panel, in asp .net. If we kept the one update panel inside the another update panel then it is called Nesting update panel.
It is important to understand there are two mode in update panel : Always and conditional.
Always: if the update mode is Always then it update on each Postback, but if it conditional, then it update the panel whenever it required.

Note: Each update panel has some methods and property Like Update(),This method is used to update that update panel from C# code,We can able to add control inside the update panel  by the help of Update panel(ID).control.Add(control ID).



Important point about update panel:

1 The Update panel is used to perform the Asynchronous  post back.
2. whenever we want to add  update panel we must have to  add  Script manager on that page.
the script manager used to register the update panel.
3 In Async post back complete life cycle event occurs but the browser only display that part where there  is update panel not complete page.
4 The Async post back used to XMLHTTPRequest to perform the  client server request.