R A M M E H T A • 8 + years experience in IT industry. • Recognized mentor to industry rookies. • Good knowledge in .NET technologies and SQL DB technologies. Y O U R T U R N F O R A Q U I C K I N T R O D U C T I O N . SOME HANDS ON BEFORE WE GET GOING ... • Find number of words in the String “ helloMyNameIsRam ” ! • Reverse the String “ Navrachana ” ! • Check if a number is Prime or not ! • Print Fibonacci sequence for first 10 values. • Find out if of “ vana ” is subsequence of “ Na v r a cha na ” • Find a prime number between a particular range. For e.g. if input is 1 and 10 then 2 3 5 7 should be printed. – Print the difference between the first and the last.. 7 - 2 = 5 5 should be the output. DATA TYPES Type Description Range byte 8 - bit unsigned integer 0 to 255 sbyte 8 - bit signed integer - 128 to 127 short 16 - bit signed integer - 32,768 to 32,767 ushort 16 - bit unsigned integer 0 to 65,535 int 32 - bit signed integer - 2,147,483,648 to 2,147,483,647 uint 32 - bit unsigned integer 0 to 4,294,967,295 long 64 - bit signed integer - 9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 ulong 64 - bit unsigned integer 0 to 18,446,744,073,709,551,615 float 32 - bit Single - precision floating point type - 3.402823e38 to 3.402823e38 double 64 - bit double - precision floating point type - 1.79769313486232e308 to 1.79769313486232e308 decimal 128 - bit decimal type for financial and monetary calculations (+ or - )1.0 x 10e - 28 to 7.9 x 10e28 char 16 - bit single Unicode character Any valid character, e.g. a,*, \ x0058 (hex), or \ u0058 (Unicode) bool 8 - bit logical true/false value True or False object Base type of all other types. string A sequence of Unicode characters DateTim e Represents date and time 0 : 00 : 00 am 1 / 1 / 01 to 11 : 59 : 59 pm 12 / 31 / 9999 VALUE TYPE AND REFERENCE TYPE • Value : VALUE TYPE AND REFERENCE TYPE • Reference : FUNCTIONS AND SUBROUTINES NAMESPACES APP CODE FOLDER • You can store source code in the App_Code folder, and it will be automatically compiled at run time. No need to compile independently. • The resulting assembly is accessible to any other code in the Web application. • The App_Code folder can contain source code files written in different languages. However, it can also include files that are not explicitly in a specific programming language. Examples include . wsdl (Web service description language) files and XML schema (. xsd ) files. ASP.NET can compile these files into assemblies. • The App_Code folder can contain as many files and subfolders as you need. You can organize your source code in any way that you find convenient, and ASP.NET will still compile all of the code into a single assembly that is accessible to other code anywhere in the Web application. APP_CODE FOLDER ! APP_CODE FOLDER ! EXCEPTION HANDLING Class Main { try { B b = new B(); b.throwError (); } catch(Exception e) { Console.WriteLine ( “ In Main ” ); } Class B { try { throwError () {throw new Exception()} } catch(Exception e) { Console.WriteLine ( “ In B ” ); } ERROR HANDLING • Application Level : You can handle default errors at the application level either by modifying your application's configuration or by adding an Application_Error handler in the Global.asax file of your application. ERROR HANDLING • Page Level : You would typically use a page - level error handler to log unhandled errors or to take the user to a page that can display helpful information. STATE MANAGEMENT ! • Stateless : • HTTP is a stateless protocol. • HTTP is a relatively simple file transfer protocol: – Make a request for a file named by a URL. – Get the file in response. – Disconnect. • There was no relationship maintained between one connection and another, even from the same client. This simplifies the contract between client and server, and in many cases minimizes the amount of data that needs to be transferred. • If web application is capable of remembering a client data during a session across the multiple requests, then that web application is called a stateful web application. In stateful web applications the web resource programs can use the data of previous request, while processing current request, that is while processing request 2 , it can use request 1 data. STATE MANAGEMENT ! • Client Side : Whenever we use Client - Side State Management, the state related information will directly get stored on the client - side. • Server Side : Operationally and functionally it is similar the client side, but here the information is stored in the user memory. STATE MANAGEMENT ! • Viewstate : In general, we can say it is used for storing user data in ASP.NET, sometimes in ASP.NET applications the user wants to maintain or store their data temporarily after a post - back.. In this case VIEW STATE is the most used and preferred way of doing that. SCOPE : PAGE. STATE MANAGEMENT ! • Viewstate : A Web application is stateless. A new instance of the Web page class is created every time that the page is requested from the server. This would ordinarily mean that all information in the page and in its controls would be lost with each round trip. For example, by default if a user enters information into a text box on an HTML Web page, that information is sent to the server. However, it is not returned to the browser in the response. To overcome this intrinsic limitation of Web programming, the ASP.NET page framework includes several state - management features to preserve page and control values between round trips to the Web server. One of these features is view state When to use ? View state is used automatically by the ASP.NET page framework to persist information that must be preserved between post backs. This information includes any non - default values of controls. You can also use view state to store application data that is specific to a page. You can use view state in your own applications to do the following: • Keep values between post backs without storing them in session state or in a user profile. • Store the values of page or control properties that you define. • Create a custom view state provider that lets you store view state information in a SQL Server database or in another data store. • For example, you can store information in view state that your code can access during the page load event the next time that the page is sent to the server. STATE MANAGEMENT ! Points to remember : • View state provides state information for a specific ASP.NET page. If you need to use information on more than one page, or if you need the information to persist across visits to the Web site, you must use another method for maintaining state. • View state information is serialized into XML and then encoded by using base - 64 encoding, which can generate large amounts of data. When the page is posted to the server, the contents of view state are sent as part of the page postback information. If view state contains a large amount of information, it can affect performance of the page. STATE MANAGEMENT !