asp practical file.docx

96
Experiment No. 1 Aim: - Introduction Of .Net Framework. Introduction: .NET Framework (pronounced dot net) is a software framework developed by Microsoft that runs primarily on Microsoft Windows. It includes a large library and provides language interoperability (each language can use code written in other languages) across several programming languages. Programs written for .NET Framework execute in a software environment (as contrasted to hardware environment), known as the Common Language Runtime (CLR), an application virtual machine that provides services such as security, memory management, and exception handling. The class library and the CLR together constitute .NET Framework. .NET Framework's Base Class Library provides user interface, data access, database connectivity, cryptography, web application development, numeric algorithms, and network communications. Programmers produce software by combining their own source code with .NET Framework and other libraries. .NET Framework is intended to be used by most new applications created for the Windows platform. Microsoft also produces an integrated development environment largely for .NET software called Visual Studio. 1

Upload: anilgoyal

Post on 17-Sep-2015

22 views

Category:

Documents


0 download

TRANSCRIPT

Experiment No. 1

Aim: - Introduction Of .Net Framework.

Introduction:.NET Framework (pronounced dot net) is a software framework developed by Microsoft that runs primarily on Microsoft Windows. It includes a large library and provides language interoperability (each language can use code written in other languages) across several programming languages. Programs written for .NET Framework execute in a software environment (as contrasted to hardware environment), known as the Common Language Runtime (CLR), an application virtual machine that provides services such as security, memory management, and exception handling. The class library and the CLR together constitute .NET Framework..NET Framework's Base Class Library provides user interface, data access, database connectivity, cryptography, web application development, numeric algorithms, and network communications. Programmers produce software by combining their own source code with .NET Framework and other libraries. .NET Framework is intended to be used by most new applications created for the Windows platform. Microsoft also produces an integrated development environment largely for .NET software called Visual Studio.

Microsoft started development of .NET Framework in the late 1990s, originally under the name of Next Generation Windows Services (NGWS). By late 2000 the first beta versions of .NET 1.0 were released.Version 3.0 of .NET Framework is included with Windows Server 2008 and Windows Vista. Version 3.5 is included with Windows 7 and Windows Server 2008 R2, and can also be installed on Windows XP and Windows Server 2003. On 12 April 2010, .NET Framework 4 was released alongside Visual Studio 2010..NET Framework family also includes two versions for mobile or embedded device use. A reduced version of the framework, .NET Compact Framework, is available on Windows CE platforms, including Windows Mobile devices such as smartphones. Additionally, .NET Micro Framework is targeted at severely resource-constrained devices.Overview of .NET Framework release history

GenerationVersion numberRelease dateDevelopment toolDistributed with

1.01.0.3705.02002-02-13Visual Studio .NETN/A

1.11.1.4322.5732003-04-24Visual Studio .NET 2003Windows Server 2003

2.02.0.50727.422005-11-07Visual Studio 2005Windows Server 2003 R2

3.03.0.4506.302006-11-06Expression BlendWindows Vista, Windows Server 2008

3.53.5.21022.82007-11-19Visual Studio 2008Windows 7, Windows Server 2008 R2

4.04.0.30319.12010-04-12Visual Studio 2010N/A

4.54.5.50709.179292012-08-15Visual Studio 2012Windows 8, Windows Server 2012

4.5.14.5.50938.184082013-10-17Visual Studio 2013Windows 8.1, Windows Server 2012 R2

Design featuresInteroperabilityBecause computer systems commonly require interaction between newer and older applications, .NET Framework provides means to access functionality implemented in newer and older programs that execute outside .NET environment. Access to COM components is provided in the System.Runtime.InteropServices and System.EnterpriseServices namespaces of the framework; access to other functionality is achieved using the P/Invoke feature.Common Language Runtime engineThe Common Language Runtime (CLR) serves as the execution engine of .NET Framework. All .NET programs execute under the supervision of the CLR, guaranteeing certain properties and behaviors in the areas of memory management, security, and exception handling.

Language independence.NET Framework introduces a Common Type System, or CTS. The CTS specification defines all possible datatypes and programming constructs supported by the CLR and how they may or may not interact with each other conforming to the Common Language Infrastructure (CLI) specification. Because of this feature, .NET Framework supports the exchange of types and object instances between libraries and applications written using any conforming .NET language.

Base Class LibraryThe Base Class Library (BCL), part of the Framework Class Library (FCL), is a library of functionality available to all languages using .NET Framework. The BCL provides classes that encapsulate a number of common functions, including file reading and writing, graphic rendering, database interaction, XML document manipulation, and so on. It consists of classes, interfaces of reusable types that integrates with CLR(Common Language Runtime).

Simplified deployment.NET Framework includes design features and tools which help manage the installation of computer software to ensure it does not interfere with previously installed software, and it conforms to security requirements.

SecurityThe design addresses some of the vulnerabilities, such as buffer overflows, which have been exploited by malicious software. Additionally, .NET provides a common security model for all applications.

PortabilityWhile Microsoft has never implemented the full framework on any system except Microsoft Windows, it has engineered the framework to be platform-agnostic and cross-platform implementations are available for other operating systems Microsoft submitted the specifications for the Common Language Infrastructure (which includes the core class libraries, Common Type System, and the Common Intermediate Language), the C# language and the C++/CLI language to both ECMA and the ISO, making them available as official standards. This makes it possible for third parties to create compatible implementations of the framework and its languages on other platforms. Architecture

Visual overview of the Common Language Infrastructure (CLI)Common Language Infrastructure (CLI)The purpose of the Common Language Infrastructure (CLI) is to provide a language-neutral platform for application development and execution, including functions for exception handling, garbage collection, security, and interoperability. By implementing the core aspects of .NET Framework within the scope of the CLI, this functionality will not be tied to a single language but will be available across the many languages supported by the framework. Microsoft's implementation of the CLI is called the Common Language Runtime, or CLR.The CIL code is housed in CLI assemblies. As mandated by the specification, assemblies are stored in the Portable Executable (PE) format, common on the Windows platform for all DLL and EXE files. The assembly consists of one or more files, one of which must contain the manifest, which has the metadata for the assembly. The complete name of an assembly (not to be confused with the filename on disk) contains its simple text name, version number, culture, and public key token. Assemblies are considered equivalent if they share the same complete name, excluding the revision of the version number. A private key can also be used by the creator of the assembly for strong naming. The public key token identifies which public key an assembly is signed with. Only the creator of the keypair (typically .NET developer signing the assembly) can sign assemblies that have the same strong name as a previous version assembly, since the creator is in possession of the private key. Strong naming is required to add assemblies to the Global Assembly Cache.Security.NET has its own security mechanism with two general features: Code Access Security (CAS), and validation and verification. Code Access Security is based on evidence that is associated with a specific assembly. Typically the evidence is the source of the assembly (whether it is installed on the local machine or has been downloaded from the intranet or Internet). Code Access Security uses evidence to determine the permissions granted to the code. Other code can demand that calling code is granted a specified permission. The demand causes the CLR to perform a call stack walk: every assembly of each method in the call stack is checked for the required permission; if any assembly is not granted the permission a security exception is thrown.Class libraryNamespaces in the BCL

System

System.Diagnostics

System.Globalization

System.Resources

System.Text

System.Runtime.Serialization

System.Data

.NET Framework includes a set of standard class libraries. The class library is organized in a hierarchy of namespaces. Most of the built-in APIs are part of either System.* or Microsoft.* namespaces. These class libraries implement a large number of common functions, such as file reading and writing, graphic rendering, database interaction, and XML document manipulation, among others. .NET class libraries are available to all CLI compliant languages. .NET Framework class library is divided into two parts: the Base Class Library and the Framework Class LibraryThe Base Class Library (BCL) includes a small subset of the entire class library and is the core set of classes that serve as the basic API of the Common Language Runtime. The classes in mscorlib.dll and some of the classes in System.dll and System.core.dll are considered to be a part of the BCL. The BCL classes are available in both .NET Framework as well as its alternative implementations including .NET Compact Framework, Microsoft Silverlight and Mono.The Framework Class Library (FCL) is a superset of the BCL classes and refers to the entire class library that ships with .NET Framework. It includes an expanded set of libraries, including Windows Forms, ADO.NET, ASP.NET, Language Integrated Query, Windows Presentation Foundation, Windows Communication Foundation among others. The FCL is much larger in scope than standard libraries for languages like C++, and comparable in scope to the standard libraries of Java.Memory management.NET Framework CLR frees the developer from the burden of managing memory (allocating and freeing up when done); it handles memory management itself by detecting when memory can be safely freed. Instantiations of .NET types (objects) are allocated from the managed heap; a pool of memory managed by the CLR. As long as there exists a reference to an object, which might be either a direct reference to an object or via a graph of objects, the object is considered to be in use. When there is no reference to an object, and it cannot be reached or used, it becomes garbage, eligible for collection. .NET Framework includes a garbage collector which runs periodically, on a separate thread from the application's thread, that enumerates all the unusable objects and reclaims the memory allocated to them..NET Garbage Collector (GC) is a non-deterministic, compacting, mark-and-sweep garbage collector. The GC runs only when a certain amount of memory has been used or there is enough pressure for memory on the system. Since it is not guaranteed when the conditions to reclaim memory are reached, the GC runs are non-deterministic. Each .NET application has a set of roots, which are pointers to objects on the managed heap (managed objects). These include references to static objects and objects defined as local variables or method parameters currently in scope, as well as objects referred to by CPU registers. When the GC runs, it pauses the application, and for each object referred to in the root, it recursively enumerates all the objects reachable from the root objects and marks them as reachable. It uses CLI metadata and reflection to discover the objects encapsulated by an object, and then recursively walk them. It then enumerates all the objects on the heap (which were initially allocated contiguously) using reflection. All objects not marked as reachable are garbage. This is the mark phase. Since the memory held by garbage is not of any consequence, it is considered free space. However, this leaves chunks of free space between objects which were initially contiguous. The objects are then compacted together to make used memory contiguous again. Any reference to an object invalidated by moving the object is updated by the GC to reflect the new location. The application is resumed after the garbage collection is over.The GC used by .NET Framework is also generational. Objects are assigned a generation; newly created objects belong to Generation 0. The objects that survive a garbage collection are tagged as Generation 1, and the Generation 1 objects that survive another collection are Generation 2 objects. .NET Framework uses up to Generation 2 objects. Higher generation objects are garbage collected less frequently than lower generation objects. This helps increase the efficiency of garbage collection, as older objects tend to have a longer lifetime than newer objects. Thus, by eliminating older (and thus more likely to survive a collection) objects from the scope of a collection run, fewer objects need to be checked and compacted. Alternative implementations.NET Framework is the predominant implementation of .NET technologies. Other implementations for parts of the framework exist. Although the runtime engine is described by an ECMA/ISO specification, other implementations of it may be encumbered by patent issues; ISO standards may include the disclaimer, "Attention is drawn to the possibility that some of the elements of this document may be the subject of patent rights. ISO shall not be held responsible for identifying any or all such patent rights." It is more difficult to develop alternatives to the base class library (BCL), which is not described by an open standard and may be subject to copyright restrictions. Additionally, parts of the BCL have Windows-specific functionality and behavior, so implementation on non-Windows platforms can be problematic.Some alternative implementations of parts of the framework are listed here. .NET Micro Framework is a .NET platform for extremely resource-constrained devices. It includes a small version of .NET CLR and supports development in C# (though some developers were able to use VB.NET, albeit with an amount of hacking, and with limited functionalities) and debugging (in an emulator or on hardware), both using Microsoft Visual Studio. It also features a subset of .NET base class libraries (about 70 classes with about 420 methods), a GUI framework loosely based on Windows Presentation Foundation, and additional libraries specific to embedded applications. Mono is an implementation of the CLI and .NET Base Class Library (BCL), and provides additional functionality. It is dual-licensed under free software and proprietary software licenses. It includes support for ASP.NET, ADO.NET, and Windows Forms libraries for a wide range of architectures and operating systems. It also includes C# and VB.NET compilers. Portable.NET provides an implementation of the Common Language Infrastructure (CLI), portions of .NET Base Class Library (BCL), and a C# compiler. It supports a variety of CPUs and operating systems. Microsoft's Shared Source Common Language Infrastructure is a non-free implementation of the CLR component of .NET Framework. However, the last version only runs on Microsoft Windows XP SP2, and was not updated since 2006, therefore it does not contain all features of version 2.0 of .NET Framework. CrossNet is an implementation of the CLI and portions of .NET Base Class Library (BCL). It is free software using the open source MIT License.PerformanceThe garbage collector, which is integrated into the environment, can introduce unanticipated delays of execution over which the developer has little direct control, and it can cause runtime memory size to be larger than expected. "In large applications, the number of objects that the garbage collector needs to deal with can become very large, which means it can take a very long time to visit and rearrange all of them." .NET Framework currently does not provide support for calling Streaming SIMD Extensions (SSE) via managed code. However, Mono has provided support for SIMD Extensions as of version 2.2 within the Mono.Simd namespace; Mono's lead developer Miguel de Icaza has expressed hope that this SIMD support will be adopted by the CLR ECMA standard. Streaming SIMD Extensions have been available in x86 CPUs since the introduction of the Pentium III. Some other architectures such as ARM and MIPS also have SIMD extensions. In case the CPU lacks support for those extensions, the instructions are simulated in software.

SecurityUnobfuscated managed CIL bytecode can often be easier to reverse-engineer than native code. One concern is over possible loss of trade secrets and the bypassing of license control mechanisms. To mitigate this, Microsoft has included the Dotfuscator Community Edition obfuscation tool within Visual Studio .NET since 2002. Third-party obfuscation tools are also available from vendors such as vmware, V.i. Labs, Xenocode, Red Gate Software. Method level encryption tools for .NET code are available from vendors such as SafeNet..NET decompiler programs enable developers with no reverse-engineering skills to view the source code behind unobfuscated .NET assemblies (DLL/EXE). In contrast, applications built with Visual C++ are much harder to reverse-engineer and source code is almost never produced successfully, mainly due to compiler optimizations and lack of reflection.AvailabilityWhile the standards that make up .NET are inherently cross-platform, Microsoft's full implementation of .NET is supported only on Microsoft Window

Experiment No. 2Aim:- Adding Two Numbers Using Windows Forms.

Form1.Designer.cs:

namespace SUM{ partial class Form1 { /// /// Required designer variable. /// private System.ComponentModel.IContainer components = null;

/// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); }

#region Windows Form Designer generated code

/// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.label1 = new System.Windows.Forms.Label(); this.TxtNum1 = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); this.TxtNum2 = new System.Windows.Forms.TextBox(); this.label3 = new System.Windows.Forms.Label(); this.TxtResult = new System.Windows.Forms.TextBox(); this.BtnSum = new System.Windows.Forms.Button(); this.BtnClose = new System.Windows.Forms.Button(); this.SuspendLayout(); // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(30, 39); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(39, 13); this.label1.TabIndex = 0; this.label1.Text = "1st no."; // // TxtNum1 // this.TxtNum1.Location = new System.Drawing.Point(75, 39); this.TxtNum1.Name = "TxtNum1"; this.TxtNum1.Size = new System.Drawing.Size(151, 20); this.TxtNum1.TabIndex = 1; // // label2 // this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(33, 94); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(43, 13); this.label2.TabIndex = 2; this.label2.Text = "2nd no."; // // TxtNum2 // this.TxtNum2.Location = new System.Drawing.Point(75, 94); this.TxtNum2.Name = "TxtNum2"; this.TxtNum2.Size = new System.Drawing.Size(151, 20); this.TxtNum2.TabIndex = 3; // // label3 // this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(36, 143); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(32, 13); this.label3.TabIndex = 4; this.label3.Text = "result"; // // TxtResult // this.TxtResult.Location = new System.Drawing.Point(74, 143); this.TxtResult.Name = "TxtResult"; this.TxtResult.Size = new System.Drawing.Size(152, 20); this.TxtResult.TabIndex = 5; // // BtnSum // this.BtnSum.Location = new System.Drawing.Point(0, 198); this.BtnSum.Name = "BtnSum"; this.BtnSum.Size = new System.Drawing.Size(75, 23); this.BtnSum.TabIndex = 6; this.BtnSum.Text = "sum"; this.BtnSum.UseVisualStyleBackColor = true; this.BtnSum.Click += new System.EventHandler(this.BtnSum_Click); // // BtnClose // this.BtnClose.Location = new System.Drawing.Point(190, 198); this.BtnClose.Name = "BtnClose"; this.BtnClose.Size = new System.Drawing.Size(75, 23); this.BtnClose.TabIndex = 7; this.BtnClose.Text = "close"; this.BtnClose.UseVisualStyleBackColor = true; this.BtnClose.Click += new System.EventHandler(this.BtnClose_Click); // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(292, 266); this.Controls.Add(this.BtnClose); this.Controls.Add(this.BtnSum); this.Controls.Add(this.TxtResult); this.Controls.Add(this.label3); this.Controls.Add(this.TxtNum2); this.Controls.Add(this.label2); this.Controls.Add(this.TxtNum1); this.Controls.Add(this.label1); this.Name = "Form1"; this.Text = "Form1"; this.ResumeLayout(false); this.PerformLayout();

}

#endregion

private System.Windows.Forms.Label label1; private System.Windows.Forms.TextBox TxtNum1; private System.Windows.Forms.Label label2; private System.Windows.Forms.TextBox TxtNum2; private System.Windows.Forms.Label label3; private System.Windows.Forms.TextBox TxtResult; private System.Windows.Forms.Button BtnSum; private System.Windows.Forms.Button BtnClose; }}

FORM.1(BUTTON CODING)using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;

namespace SUM{ public partial class Form1 : Form { public Form1() { InitializeComponent(); }

private void BtnSum_Click(object sender, EventArgs e) { TxtResult.Text = (Convert.ToInt32(TxtNum1.Text) + Convert.ToInt32(TxtNum2.Text)).ToString(); }

private void BtnClose_Click(object sender, EventArgs e) { this.Close(); } }}

Output Screen:-

Experiment No. 3Aim: To Develop A Timed Math Quiz.

SOURCE CODE:

FORM1.DESIGNER.CS CODING:namespace Math_Quiz{ partial class Form1 { /// /// Required designer variable. /// private System.ComponentModel.IContainer components = null;

/// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); }

#region Windows Form Designer generated code

/// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.timeLabel = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); this.plusLeftLabel = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.plusRightLabel = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); this.sum = new System.Windows.Forms.NumericUpDown(); this.difference = new System.Windows.Forms.NumericUpDown(); this.label3 = new System.Windows.Forms.Label(); this.minusRightLabel = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); this.minusLeftLabel = new System.Windows.Forms.Label(); this.product = new System.Windows.Forms.NumericUpDown(); this.label5 = new System.Windows.Forms.Label(); this.timesRightLabel = new System.Windows.Forms.Label(); this.label8 = new System.Windows.Forms.Label(); this.timesLeftLabel = new System.Windows.Forms.Label(); this.quotient = new System.Windows.Forms.NumericUpDown(); this.label10 = new System.Windows.Forms.Label(); this.dividedRightLabel = new System.Windows.Forms.Label(); this.label12 = new System.Windows.Forms.Label(); this.dividedLeftLabel = new System.Windows.Forms.Label(); this.startButton = new System.Windows.Forms.Button(); this.timer1 = new System.Windows.Forms.Timer(this.components); ((System.ComponentModel.ISupportInitialize)(this.sum)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.difference)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.product)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.quotient)).BeginInit(); this.SuspendLayout(); // // timeLabel // this.timeLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.timeLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.timeLabel.Location = new System.Drawing.Point(272, 9); this.timeLabel.Name = "timeLabel"; this.timeLabel.Size = new System.Drawing.Size(200, 30); this.timeLabel.TabIndex = 0; this.timeLabel.Enter += new System.EventHandler(this.answer_Enter); // // label1 // this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label1.Location = new System.Drawing.Point(154, 9); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(112, 30); this.label1.TabIndex = 1; this.label1.Text = "Time Left"; // // plusLeftLabel // this.plusLeftLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.plusLeftLabel.Location = new System.Drawing.Point(52, 75); this.plusLeftLabel.Name = "plusLeftLabel"; this.plusLeftLabel.Size = new System.Drawing.Size(60, 50); this.plusLeftLabel.TabIndex = 2; this.plusLeftLabel.Text = "?"; this.plusLeftLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // label2 // this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label2.Location = new System.Drawing.Point(103, 75); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(60, 50); this.label2.TabIndex = 3; this.label2.Text = "+"; this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // plusRightLabel // this.plusRightLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.plusRightLabel.Location = new System.Drawing.Point(154, 75); this.plusRightLabel.Name = "plusRightLabel"; this.plusRightLabel.Size = new System.Drawing.Size(60, 50); this.plusRightLabel.TabIndex = 4; this.plusRightLabel.Text = "?"; this.plusRightLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // label4 // this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label4.Location = new System.Drawing.Point(208, 75); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(60, 50); this.label4.TabIndex = 5; this.label4.Text = "="; this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // sum // this.sum.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.sum.Location = new System.Drawing.Point(274, 84); this.sum.Name = "sum"; this.sum.Size = new System.Drawing.Size(100, 35); this.sum.TabIndex = 2; this.sum.Enter += new System.EventHandler(this.answer_Enter); // // difference // this.difference.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.difference.Location = new System.Drawing.Point(274, 140); this.difference.Name = "difference"; this.difference.Size = new System.Drawing.Size(100, 35); this.difference.TabIndex = 3; this.difference.Enter += new System.EventHandler(this.answer_Enter); // // label3 // this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label3.Location = new System.Drawing.Point(208, 131); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(60, 50); this.label3.TabIndex = 10; this.label3.Text = "="; this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // minusRightLabel // _ this.minusRightLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.minusRightLabel.Location = new System.Drawing.Point(154, 131); this.minusRightLabel.Name = "minusRightLabel"; this.minusRightLabel.Size = new System.Drawing.Size(60, 50); this.minusRightLabel.TabIndex = 9; this.minusRightLabel.Text = "?"; this.minusRightLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // label6 // this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label6.Location = new System.Drawing.Point(103, 131); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(60, 50); this.label6.TabIndex = 8; this.label6.Text = "-"; this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // minusLeftLabel // this.minusLeftLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.minusLeftLabel.Location = new System.Drawing.Point(52, 131); this.minusLeftLabel.Name = "minusLeftLabel"; this.minusLeftLabel.Size = new System.Drawing.Size(60, 50); this.minusLeftLabel.TabIndex = 7; this.minusLeftLabel.Text = "?"; this.minusLeftLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // product // this.product.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.product.Location = new System.Drawing.Point(274, 197); this.product.Name = "product"; this.product.Size = new System.Drawing.Size(100, 35); this.product.TabIndex = 4; this.product.Enter += new System.EventHandler(this.answer_Enter); // // label5 // this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label5.Location = new System.Drawing.Point(208, 188); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(60, 50); this.label5.TabIndex = 15; this.label5.Text = "="; this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // timesRightLabel // this.timesRightLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.timesRightLabel.Location = new System.Drawing.Point(154, 188); this.timesRightLabel.Name = "timesRightLabel"; this.timesRightLabel.Size = new System.Drawing.Size(60, 50); this.timesRightLabel.TabIndex = 14; this.timesRightLabel.Text = "?"; this.timesRightLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // label8 // this.label8.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label8.Location = new System.Drawing.Point(103, 188); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(60, 50); this.label8.TabIndex = 13; this.label8.Text = ""; this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // timesLeftLabel // this.timesLeftLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.timesLeftLabel.Location = new System.Drawing.Point(52, 188); this.timesLeftLabel.Name = "timesLeftLabel"; this.timesLeftLabel.Size = new System.Drawing.Size(60, 50); this.timesLeftLabel.TabIndex = 12; this.timesLeftLabel.Text = "?"; this.timesLeftLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // quotient // this.quotient.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.quotient.Location = new System.Drawing.Point(272, 252); this.quotient.Name = "quotient"; this.quotient.Size = new System.Drawing.Size(100, 35); this.quotient.TabIndex = 5; this.quotient.Enter += new System.EventHandler(this.answer_Enter); // // label10 // this.label10.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label10.Location = new System.Drawing.Point(206, 243); this.label10.Name = "label10"; this.label10.Size = new System.Drawing.Size(60, 50); this.label10.TabIndex = 20; this.label10.Text = "="; this.label10.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // dividedRightLabel // this.dividedRightLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.dividedRightLabel.Location = new System.Drawing.Point(152, 243); this.dividedRightLabel.Name = "dividedRightLabel"; this.dividedRightLabel.Size = new System.Drawing.Size(60, 50); this.dividedRightLabel.TabIndex = 19; this.dividedRightLabel.Text = "?"; this.dividedRightLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // label12 // this.label12.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label12.Location = new System.Drawing.Point(101, 243); this.label12.Name = "label12"; this.label12.Size = new System.Drawing.Size(60, 50); this.label12.TabIndex = 18; this.label12.Text = ""; this.label12.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // dividedLeftLabel // this.dividedLeftLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.dividedLeftLabel.Location = new System.Drawing.Point(50, 243); this.dividedLeftLabel.Name = "dividedLeftLabel"; this.dividedLeftLabel.Size = new System.Drawing.Size(60, 50); this.dividedLeftLabel.TabIndex = 17; this.dividedLeftLabel.Text = "?"; this.dividedLeftLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // startButton // this.startButton.AutoSize = true; this.startButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.startButton.Location = new System.Drawing.Point(157, 315); this.startButton.Name = "startButton"; this.startButton.Size = new System.Drawing.Size(127, 34); this.startButton.TabIndex = 1; this.startButton.Text = "Start the quiz"; this.startButton.UseVisualStyleBackColor = true; this.startButton.Click += new System.EventHandler(this.startButton_Click); // // timer1 // this.timer1.Interval = 1000; this.timer1.Tick += new System.EventHandler(this.timer1_Tick); // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(484, 361); this.Controls.Add(this.startButton); this.Controls.Add(this.quotient); this.Controls.Add(this.label10); this.Controls.Add(this.dividedRightLabel); this.Controls.Add(this.label12); this.Controls.Add(this.dividedLeftLabel); this.Controls.Add(this.product); this.Controls.Add(this.label5); this.Controls.Add(this.timesRightLabel); this.Controls.Add(this.label8); this.Controls.Add(this.timesLeftLabel); this.Controls.Add(this.difference); this.Controls.Add(this.label3); this.Controls.Add(this.minusRightLabel); this.Controls.Add(this.label6); this.Controls.Add(this.minusLeftLabel); this.Controls.Add(this.sum); this.Controls.Add(this.label4); this.Controls.Add(this.plusRightLabel); this.Controls.Add(this.label2); this.Controls.Add(this.plusLeftLabel); this.Controls.Add(this.label1); this.Controls.Add(this.timeLabel); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D; this.MaximizeBox = false; this.Name = "Form1"; this.Text = "Math Quiz"; this.Load += new System.EventHandler(this.Form1_Load); ((System.ComponentModel.ISupportInitialize)(this.sum)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.difference)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.product)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.quotient)).EndInit(); this.ResumeLayout(false); this.PerformLayout();

}

#endregion

private System.Windows.Forms.Label timeLabel; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label plusLeftLabel; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label plusRightLabel; private System.Windows.Forms.Label label4; private System.Windows.Forms.NumericUpDown sum; private System.Windows.Forms.NumericUpDown difference; private System.Windows.Forms.Label label3; private System.Windows.Forms.Label minusRightLabel; private System.Windows.Forms.Label label6; private System.Windows.Forms.Label minusLeftLabel; private System.Windows.Forms.NumericUpDown product; private System.Windows.Forms.Label label5; private System.Windows.Forms.Label timesRightLabel; private System.Windows.Forms.Label label8; private System.Windows.Forms.Label timesLeftLabel; private System.Windows.Forms.NumericUpDown quotient; private System.Windows.Forms.Label label10; private System.Windows.Forms.Label dividedRightLabel; private System.Windows.Forms.Label label12; private System.Windows.Forms.Label dividedLeftLabel; private System.Windows.Forms.Button startButton; private System.Windows.Forms.Timer timer1; }}

FORM1.CS CODING:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;

namespace Math_Quiz{ public partial class Form1 : Form { // Create a Random object called randomizer // to generate random numbers. Random randomizer = new Random(); // These integer variables store the numbers // for the addition problem. int addend1; int addend2;

// These integer variables store the numbers // for the subtraction problem. int minuend; int subtrahend;

// These integer variables store the numbers // for the multiplication problem. int multiplicand; int multiplier;

// These integer variables store the numbers // for the division problem. int dividend; int divisor; // This integer variable keeps track of the // remaining time. int timeLeft; public Form1() { InitializeComponent(); }

private void Form1_Load(object sender, EventArgs e) { }

/// /// Call the StartTheQuiz() method and enable /// the Start button. /// private void startButton_Click(object sender, EventArgs e) { StartTheQuiz(); startButton.Enabled = false; }

/// /// Start the quiz by filling in all of the problem /// values and starting the timer. /// public void StartTheQuiz() { // Fill in the addition problem. // Generate two random numbers to add. // Store the values in the variables 'addend1' and 'addend2'. addend1 = randomizer.Next(51); addend2 = randomizer.Next(51);

// Convert the two randomly generated numbers // into strings so that they can be displayed // in the label controls. plusLeftLabel.Text = addend1.ToString(); plusRightLabel.Text = addend2.ToString();

// 'sum' is the name of the NumericUpDown control. // This step makes sure its value is zero before // adding any values to it. sum.Value = 0;

// Fill in the subtraction problem. minuend = randomizer.Next(1, 101); subtrahend = randomizer.Next(1, minuend); minusLeftLabel.Text = minuend.ToString(); minusRightLabel.Text = subtrahend.ToString(); difference.Value = 0;

// Fill in the multiplication problem. multiplicand = randomizer.Next(2, 11); multiplier = randomizer.Next(2, 11); timesLeftLabel.Text = multiplicand.ToString(); timesRightLabel.Text = multiplier.ToString(); product.Value = 0;

// Fill in the division problem. divisor = randomizer.Next(2, 11); int temporaryQuotient = randomizer.Next(2, 11); dividend = divisor * temporaryQuotient; dividedLeftLabel.Text = dividend.ToString(); dividedRightLabel.Text = divisor.ToString(); quotient.Value = 0; // Start the timer. timeLeft = 30; timeLabel.Text = "30 seconds"; timer1.Start(); }

/// /// Time the quiz. /// private void timer1_Tick(object sender, EventArgs e) { if (CheckTheAnswer()) { // If CheckTheAnswer() returns true, then the user // got the answer right. Stop the timer // and show a MessageBox. timer1.Stop(); MessageBox.Show("You got all the answers right!", "Congratulations!"); startButton.Enabled = true; } else if (timeLeft > 0) { // If CheckTheAnswer() return false, keep counting // down. Decrease the time left by one second and // display the new time left by updating the // Time Left label. timeLeft--; timeLabel.Text = timeLeft + " seconds"; } else { // If the user ran out of time, stop the timer, show // a MessageBox, and fill in the answers. timer1.Stop(); timeLabel.Text = "Time's up!"; MessageBox.Show("You didn't finish in time.", "Sorry!"); sum.Value = addend1 + addend2; difference.Value = minuend - subtrahend; product.Value = multiplicand * multiplier; quotient.Value = dividend / divisor; startButton.Enabled = true; } }

/// /// Check the answers to see if the user got everything right. /// /// True if the answers are correct, false otherwise. private bool CheckTheAnswer() { if ((addend1 + addend2 == sum.Value) && (minuend - subtrahend == difference.Value) && (multiplicand * multiplier == product.Value) && (dividend / divisor == quotient.Value)) return true; else return false; }

/// /// Modify the behavior of the NumericUpDown control /// to make it easier to enter numeric values for /// the quiz. /// private void answer_Enter(object sender, EventArgs e) { // Select the whole answer in the NumericUpDown control. NumericUpDown answerBox = sender as NumericUpDown; if (answerBox != null) { int lengthOfAnswer = answerBox.Value.ToString().Length; answerBox.Select(0, lengthOfAnswer); } } }}

OUTPUT:

Experiment No. 4Aim:- Write An Asp.Net Program To Display The Following Web Control:A Button With Text Click Me. The Button Control Must Be In The Centre Of The Form

DESIGNER PAGE:

Web Controls

Experiment No. 5Aim:- Study About Ado .Net

INTRODUCTION:ADO.NET is a set of computer software components that programmers can use to access data and data services based on disconnected DataSets and XML. It is a part of the base class library that is included with the Microsoft .NET Framework. It is commonly used by programmers to access and modify data stored in relational database systems, though it can also access data in non-relational sources. ADO.NET is sometimes considered an evolution of ActiveX Data Objects (ADO) technology, but was changed so extensively that it can be considered an entirely new product.Architecture

This technology forms a part of .NET Framework 3.0 (having been part of the framework since version 1.0)ADO.NET is conceptually divided into consumers and data providers. The consumers are the applications that need access to the data, and the providers are the software components that implement the interface and thereby provide the data to the consumer.ADO.NET and Visual StudioFunctionality exists in Visual Studio IDE to create specialized subclasses of the DataSet classes for a particular database schema, allowing convenient access to each field through strongly typed properties. This helps catch more programming errors at compile-time and makes the IDE's Intellisense feature more beneficialEntity FrameworkThe ADO.NET Entity Framework is a set of data-access APIs for the Microsoft .NET Framework, similar to the Java Persistence API, targeting the version of ADO.NET that ships with .NET Framework 4.0. ADO.NET Entity Framework is included with .NET Framework 4.0 and Visual Studio 2010, released in April 2010. An Entity Framework Entity is an object which has a key representing the primary key of a logical datastore entity. A conceptual Entity Data Model (Entity-relationship model) is mapped to a datastore schema model. Using the Entity Data Model, the Entity Framework allows data to be treated as entities independently of their underlying datastore representations.Entity SQL, a SQL-like language, serves for querying the Entity Data Model (instead of the underlying datastore). Similarly, LINQ extension LINQ to Entities provides typed querying on the Entity Data Model. Entity SQL and LINQ to Entities queries are converted internally into a Canonical Query Tree which is then converted into a query understandable to the underlying database.ADO.NET provides consistent access to data sources such as SQL Server and XML, and to data sources exposed through OLE DB and ODBC. Data-sharing consumer applications can use ADO.NET to connect to these data sources and retrieve, handle, and update the data that they contain. ADO.NET separates data access from data manipulation into discrete components that can be used separately or in tandem. ADO.NET includes .NET Framework data providers for connecting to a database, executing commands, and retrieving results. Those results are either processed directly, placed in an ADO.NET DataSet object in order to be exposed to the user in an ad hoc manner, combined with data from multiple sources, or passed between tiers. The DataSet object can also be used independently of a .NET Framework data provider to manage data local to the application or sourced from XML.The ADO.NET classes are found in System.Data.dll, and are integrated with the XML classes found in System.Xml.dll. For sample code that connects to a database, retrieves data from it, and then displays that data in a console windowADO.NET provides functionality to developers who write managed code similar to the functionality provided to native component object model (COM) developers by ActiveX Data Objects (ADO). We recommend that you use ADO.NET, not ADO, for accessing data in your .NET applications. ADO.NET provides the most direct method of data access within the .NET Framework. For a higher-level abstraction that allows applications to work against a conceptual model instead of the underlying storage model, see the ADO.NET Entity Framework.Privacy Statement: The System.Data.dll, System.Data.Design.dll, System.Data.OracleClient.dll, System.Data.SqlXml.dll, System.Data.Linq.dll, System.Data.SqlServerCe.dll, and System.Data.DataSetExtensions.dll assemblies do not distinguish between a user's private data and non-private data. These assemblies do not collect, store, or transport any user's private data. However, third-party applications might collect, store, or transport a user's private data using these assemblies

Experiment No. 6Aim: Study Of C# Features.C# is a modern, general-purpose, object-oriented programming language developed by Microsoft and approved by Ecma and ISO. C# was developed by Anders Hejlsberg and his team during the development of .Net Framework.C# is designed for Common Language Infrastructure (CLI), which consists of the executable code and runtime environment that allows use of various high-level languages to be used on different computer platforms and architectures.The following reasons make C# a widely used professional language: Modern, general-purpose programming language Object oriented. Component oriented. Easy to learn. Structured language. It produces efficient programs. It can be compiled on a variety of computer platforms. Part of .Net Framework.Strong Programming Features of C#Although C# constructs closely follow traditional high-level languages C and C++ and being an object-oriented programming language, it has strong resemblance with Java, it has numerous strong programming features that make it endearing to multitude of programmers worldwide.Following is the list of few important features: Boolean Conditions Automatic Garbage Collection Standard Library Assembly Versioning Properties and Events Delegates and Events Management Easy-to-use Generics Indexers Conditional Compilation Simple Multithreading LINQ and Lambda Expressions Integration with WindowsFor example, let us consider a Rectangle object. It has attributes like length and width. Depending upon the design, it may need ways for accepting the values of these attributes, calculating area and display details. Let us look at an implementation of a Rectangle class and discuss C# basic syntax, on the basis of our observations in it:using System;namespace RectangleApplication{ class Rectangle { // member variables double length; double width; public void Acceptdetails() { length = 4.5; width = 3.5; } public double GetArea() { return length * width; } public void Display() { Console.WriteLine("Length: {0}", length); Console.WriteLine("Width: {0}", width); Console.WriteLine("Area: {0}", GetArea()); } } class ExecuteRectangle { static void Main(string[] args) { Rectangle r = new Rectangle(); r.Acceptdetails(); r.Display(); Console.ReadLine(); } }}When the above code is compiled and executed, it produces the following result:Length: 4.5Width: 3.5Area: 15.75The using KeywordThe first statement in any C# program is using System;The using keyword is used for including the namespaces in the program. A program can include multiple using statements.The class KeywordThe class keyword is used for declaring a class.Comments in C#Comments are used for explaining code. Compilers ignore the comment entries. The multiline comments in C# programs start with /* and terminates with the characters */ as shown below:/* This program demonstratesThe basic syntax of C# programming Language */Single-line comments are indicated by the '//' symbol. For example,}//end class Rectangle Member VariablesVariables are attributes or data members of a class, used for storing data. In the preceding program, the Rectangle class has two member variables named length and width.Member FunctionsFunctions are set of statements that perform a specific task. The member functions of a class are declared within the class. Our sample class Rectangle contains three member functions: AcceptDetails, GetArea and Display.Instantiating a ClassIn the preceding program, the class ExecuteRectangle is used as a class, which contains the Main() method and instantiates the Rectangle class. IdentifiersAn identifier is a name used to identify a class, variable, function, or any other user-defined item. The basic rules for naming classes in C# are as follows: A name must begin with a letter that could be followed by a sequence of letters, digits (0 - 9) or underscore. The first character in an identifier cannot be a digit. It must not contain any embedded space or symbol like ? - +! @ # % ^ & * ( ) [ ] { } . ; : " ' / and \. However, an underscore ( _ ) can be used. It should not be a C# keyword

Experiment No. 7Aim:- Study About Asp.NetINTODUCTION:ASP.NET is a server-side Web application framework designed for Web development to produce dynamic Web pages. It was developed by Microsoft to allow programmers to build dynamic web sites, web applications and web services. It was first released in January 2002 with version 1.0 of the .NET Framework, and is the successor to Microsoft's Active Server Pages (ASP) technology. ASP.NET is built on the Common Language Runtime (CLR), allowing programmers to write ASP.NET code using any supported .NET language. The ASP.NET SOAP extension framework allows ASP.NET components to process SOAP messages.CharacteristicsASP.NET Web pages, known officially as Web Forms, are the main building blocks for application development. Web forms are contained in files with a ".aspx" extension; these files typically contain static (X)HTML markup, as well as markup defining server-side Web Controls and User Controls where the developers place all the rc contentfor the Web page. Additionally, dynamic code which runs on the server can be placed in a page within a block , which is similar to other Web development technologies such as PHP, JSP, and ASP. With ASP.NET Framework 2.0, Microsoft introduced a new code-behind model which allows static text to remain on the .aspx page, while dynamic code remains in an .aspx.vb or .aspx.cs or .aspx.fs file (depending on the programming language used). DirectivesA directive is a special instruction on how ASP.NET should process the page.The most common directive is which can specify many attributes used by the ASP.NET page parser and compiler.ExamplesInline code

protected void Page_Load(object sender, EventArgs e) { // Assign the datetime to label control lbl1.Text = DateTime.Now.ToLongTimeString(); }

Sample page

Code-behind solutions

The above tag is placed at the beginning of the ASPX file. The CodeFile property of the @ Page directive specifies the file (.cs or .vb or .fs) acting as the code-behind while the Inherits property specifies the Class from which the Page is derived. In this example, the @ Page directive is included in SampleCodeBehind.aspx, then SampleCodeBehind.aspx.cs acts as the code-behind for this page:Source language C#:using System;namespace Website{ public partial class SampleCodeBehind : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Response.Write("Hello, world"); } }}Source language Visual Basic.NET:Imports SystemNamespace Website Public Partial Class SampleCodeBehind Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Response.Write("Hello, world") End Sub End ClassEnd NamespaceIn this case, the Page_Load() method is called every time the ASPX page is requested. The programmer can implement event handlers at several stages of the page execution process to perform processing.User controlsUser controls are encapsulations of sections of pages which are registered and used as controls in ASP.NET, etc.Custom controlsProgrammers can also build custom controls for ASP.NET applications. Unlike user controls, these controls do not have an ASCX markup file, having all their code compiled into a dynamic link library (DLL) file. Such custom controls can be used across multiple Web applications and Visual Studio projects.Rendering techniqueASP.NET uses a visited composites rendering technique. During compilation, the template (.aspx) file is compiled into initialization code which builds a control tree (the composite) representing the original template. Literal text goes into instances of the Literal control class, and server controls are represented by instances of a specific control class. The initialization code is combined with user-written code (usually by the assembly of multiple partial classes) and results in a class specific for the page. The page doubles as the root of the control tree.Actual requests for the page are processed through a number of steps. First, during the initialization steps, an instance of the page class is created and the initialization code is executed. This produces the initial control tree which is now typically manipulated by the methods of the page in the following steps. As each node in the tree is a control represented as an instance of a class, the code may change the tree structure as well as manipulate the properties/methods of the individual nodes. Finally, during the rendering step a visitor is used to visit every node in the tree, asking each node to render itself using the methods of the visitor. The resulting HTML output is sent to the client.After the request has been processed, the instance of the page class is discarded and with it the entire control tree. This is a source of confusion among novice ASP.NET programmers who rely on the class instance members that are lost with every page request/response cycle.State managementASP.NET applications are hosted by a Web server and are accessed using the stateless HTTP protocol. As such, if an application uses stateful interaction, it has to implement state management on its own. ASP.NET provides various functions for state management. Conceptually, Microsoft treats "state" as GUI state. Problems may arise if an application needs to keep track of "data state"; for example, a finite-state machine which may be in a transient state between requests (lazy evaluation) or which takes a long time to initialize. State management in ASP.NET pages with authentication can make Web scraping difficult or impossible.ApplicationApplication state is held by a collection of shared user-defined variables. These are set and initialized when the Application_OnStart event fires on the loading of the first instance of the application and are available until the last instance exits. Application state variables are accessed using the Applications collection, which provides a wrapper for the application state. Application state variables are identified by name. Session stateServer-side session state is held by a collection of user-defined session variables that are persistent during a user session. These variables, accessed using the Session collection, are unique to each session instance. The variables can be set to be automatically destroyed after a defined time of inactivity even if the session does not end. Client-side user session is maintained by either a cookie or by encoding the session ID in the URL itself. ASP.NET supports three modes of persistence for server-side session variables: In-process modeThe session variables are maintained within the ASP.NET process. This is the fastest way; however, in this mode the variables are destroyed when the ASP.NET process is recycled or shut down.State server modeASP.NET runs a separate Windows service that maintains the state variables. Because state management happens outside the ASP.NET process, and because the ASP.NET engine accesses data using .NET Remoting, ASPState is slower than In-Process. This mode allows an ASP.NET application to be load-balanced and scaled across multiple servers. Because the state management service runs independently of ASP.NET, the session variables can persist across ASP.NET process shutdowns. However, since session state server runs as one instance, it is still one point of failure for session state. The session-state service cannot be load-balanced, and there are restrictions on types that can be stored in a session variable.SQL Server modeState variables are stored in a database, allowing session variables to be persisted across ASP.NET process shutdowns. The main advantage of this mode is that it allows the application to balance load on a server cluster, sharing sessions between servers. This is the slowest method of session state management in ASP.NET.ASP.NET session state enables you to store and retrieve values for a user as the user navigates ASP.NET pages in a Web application. HTTP is a stateless protocol. This means that a Web server treats each HTTP request for a page as an independent request. The server retains no knowledge of variable values that were used during previous requests. ASP.NET session state identifies requests from the same browser during a limited time window as a session, and provides a way to persist variable values for the duration of that session. By default, ASP.NET session state is enabled for all ASP.NET applications.Alternatives to session state include the following: Application state, which stores variables that can be accessed by all users of an ASP.NET application. Profile properties, which persists user values in a data store without expiring them. ASP.NET caching, which stores values in memory that is available to all ASP.NET applications. View state, which persists values in a page. Cookies. The query string and fields on an HTML form that are available from an HTTP request.For a comparison of different state-management options, see ASP.NET State Management Recommendations SessionView stateView state refers to the page-level state management mechanism, utilized by the HTML pages emitted by ASP.NET applications to maintain the state of the Web form controls and widgets. The state of the controls is encoded and sent to the server at every form submission in a hidden field known as __VIEWSTATE. The server sends back the variable so that, when the page is re-rendered, the controls render at their last state. At the server side, the application may change the viewstate, if the processing requires a change of state of any control. The states of individual controls are decoded at the server, and are available for use in ASP.NET pages using the ViewState collection. The main use for this is to preserve form information across postbacks. View state is turned on by default and normally serializes the data in every control on the page regardless of whether it is actually used during a postback. This behavior can (and should) be modified, however, as View state can be disabled on a per-control, per-page, or server-wide basis.Developers need to be wary of storing sensitive or private information in the View state of a page or control, as the base64 string containing the view state data can easily be de-serialized. By default, View state does not encrypt the __VIEWSTATE value. Encryption can be enabled on a server-wide (and server-specific) basis, allowing for a certain level of security to be maintained. Server-side cachingASP.NET offers a "Cache" object that is shared across the application and can also be used to store various objects. The "Cache" object holds the data only for a specified amount of time and is automatically cleaned after the session time-limit elapses.OtherOther means of state management that are supported by ASP.NET are cookies, caching, and using the query string.Template engineWhen first released, ASP.NET lacked a template engine. Because the .NET Framework is object-oriented and allows for inheritance, many developers would define a new base class that inherits from "System.Web.UI.Page", write methods there that render HTML, and then make the pages in their application inherit from this new class. While this allows for common elements to be reused across a site, it adds complexity and mixes source code with markup. Furthermore, this method can only be visually tested by running the application not while designing it. Other developers have used include files and other tricks to avoid having to implement the same navigation and other elements in every page.ASP.NET 2.0 introduced the concept of "master pages", which allow for template-based page development. A Web application can have one or more master pages, which, beginning with ASP.NET 2.0, can be nested. Master templates have place-holder controls, called ContentPlaceHolders to denote where the dynamic content goes, as well as HTML and JavaScript shared across child pages.Child pages use those ContentPlaceHolder controls, which must be mapped to the place-holder of the master page that the content page is populating. The rest of the page is defined by the shared parts of the master page, much like a mail merge in a word processor. All markup and server controls in the content page must be placed within the ContentPlaceHolder control.When a request is made for a content page, ASP.NET merges the output of the content page with the output of the master page, and sends the output to the user.The master page remains fully accessible to the content page. This means that the content page may still manipulate headers, change title, configure caching etc. If the master page exposes public properties or methods (e.g. for setting copyright notices) the content page can use these as well.

Experiment No.8Aim: Write A Program To Display Welcome To Radiant In The Form When The Click Button Is Clicked. The Form Title Must Be Asp.Net.

DESIGN CODING:

void Calculate(Object sender,EventArgs e){if (Store.SelectedIndex > -1){int i = Store.SelectedIndex;Cost.Text = You have chosen + Store.SelectedItem.Value + andits cost is Rs.;if (i==0)Cost.Text += 30;else if (i==1)Cost.Text += 32;else if (i == 2)Cost.Text += 28;elseCost.Text += 26;}}void display(Object sender, EventArgs e){int i = Store.SelectedIndex;if (i==0){Img.ImageUrl = Cola.gif;Img.AlternateText = Cola;}else if (i==1){Img.ImageUrl = Red_pop.gif;Img.AlternateText = Red Pop;}else if (i == 2){Img.ImageUrl = Lime.gif;Img.AlternateText = Lime;}else{Img.ImageUrl = Purple_Rain.gif;Img.AlternateText = Purple Rain;}}



ASP.NETCentre for Information Technology and Engineering, Manonmaniam Sundaranar University 16

Output-

Experiment No. 9Aim: Study About Xml (Extensible Markup Language)

Introduction:Extensible Markup Language (XML) is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. It is defined in the XML 1.0 Specification produced by the W3C, and several other related specifications, all free open standards. The design goals of XML emphasize simplicity, generality, and usability over the Internet. It is a textual data format with strong support via Unicode for the languages of the world. Although the design of XML focuses on documents, it is widely used for the representation of arbitrary data structures, for example in web services.Many application programming interfaces (APIs) have been developed to aid software developers with processing XML data, and several schema systems exist to aid in the definition of XML-based languages.Key terminologyThe material in this section is based on the XML Specification. This is not an exhaustive list of all the constructs that appear in XML; it provides an introduction to the key constructs most often encountered in day-to-day use.(Unicode) characterBy definition, an XML document is a string of characters. Almost every legal Unicode character may appear in an XML document.Processor and applicationThe processor analyzes the markup and passes structured information to an application. The specification places requirements on what an XML processor must do and not do, but the application is outside its scope. The processor (as the specification calls it) is often referred to colloquially as an XML parser.Markup and contentThe characters making up an XML document are divided into markup and content, which may be distinguished by the application of simple syntactic rules. Generally, strings that constitute markup either begin with the character < and end with a >, or they begin with the character & and end with a ;. Strings of characters that are not markup are content. However, in a CDATA section, the delimiters are classified as markup, while the text between them is classified as content. In addition, whitespace before and after the outermost element is classified as markup.TagA markup construct that begins with < and ends with >. Tags come in three flavors: start-tags; for example: end-tags; for example: empty-element tags; for example: ElementA logical document component which either begins with a start-tag and ends with a matching end-tag or consists only of an empty-element tag. The characters between the start- and end-tags, if any, are the element's content, and may contain markup, including other elements, which are called child elements. An example of an element is Hello,world. Another is .AttributeA markup construct consisting of a name/value pair that exists within a start-tag or empty-element tag. In the example (below) the element img has two attributes, src and alt:

Another example would beConnect A to B.where the name of the attribute is "number" and the value is "3".An XML attribute can only have a single value and each attribute can appear at most once on each element. In the common situation where a list of multiple values is desired, this must be done by encoding the list into a well-formed XML attribute with some format beyond what XML defines itself. Usually this is either a comma or semi-colon delimited list or, if the individual values are known not to contain spaces, a space-delimited list can be used.Hello!where the attribute "class" has both the value "inner greeting-box", indicating the CSS class names "inner" and "greeting-box".XML declarationXML documents may begin by declaring some information about themselves, as in the following example:

Characters and escapingXML documents consist entirely of characters from the Unicode repertoire. Except for a small number of specifically excluded control characters, any character defined by Unicode may appear within the content of an XML document.XML includes facilities for identifying the encoding of the Unicode characters that make up the document, and for expressing characters that, for one reason or another, cannot be used directly.

Valid charactersUnicode code points in the following ranges are valid in XML 1.0 documents: U+0009, U+000A, U+000D: these are the only C0 controls accepted in XML 1.0; U+0020U+D7FF, U+E000U+FFFD: this excludes some (not all) non-characters in the BMP (all surrogates, U+FFFE and U+FFFF are forbidden); U+10000U+10FFFF: this includes all code points in supplementary planes, including non-characters.XML 1.1 extends the set of allowed characters to include all the above, plus the remaining characters in the range U+0001U+001F. At the same time, however, it restricts the use of C0 and C1 control characters other than U+0009, U+000A, U+000D, and U+0085 by requiring them to be written in escaped form (for example U+0001 must be written as or its equivalent). In the case of C1 characters, this restriction is a backwards incompatibility; it was introduced to allow common encoding errors to be detected.The code point U+0000 is the only character that is not permitted in any XML 1.0 or 1.1 document.Encoding detectionThe Unicode character set can be encoded into bytes for storage or transmission in a variety of different ways, called "encodings". Unicode itself defines encodings that cover the entire repertoire; well-known ones include UTF-8 and UTF-16. There are many other text encodings that predate Unicode, such as ASCII and ISO/IEC 8859; their character repertoires in almost every case are subsets of the Unicode character set.XML allows the use of any of the Unicode-defined encodings, and any other encodings whose characters also appear in Unicode. XML also provides a mechanism whereby an XML processor can reliably, without any prior knowledge, determine which encoding is being used. Encodings other than UTF-8 and UTF-16 will not necessarily be recognized by every XML parser.EscapingXML provides escape facilities for including characters which are problematic to include directly. For example: The characters "" & represents "&" ' represents ' " represents "All permitted Unicode characters may be represented with a numeric character reference. Consider the Chinese character "", whose numeric code in Unicode is hexadecimal 4E2D, or decimal 20,013. A user whose keyboard offers no method for entering this character could still insert it in an XML document encoded either as or . Similarly, the string "I