.NET Framework It is a language-neutral environment for developing and building applications that can easily and securely operate within it. The components that make up the .NET platform are collectively called the .NET Framework. The .NET Framework is designed for cross language compatibility. Cross-language compatibility means, an application written in Visual Basic .NET may reference a DLL file written in C# (C-Sharp). A Visual Basic .NET class might be derived from a C# class or vice versa.
.NET Framework Advantages The .NET Framework offers a number of advantages to developers. The following paragraphs describe them in detail. Consistent Programming Model The functionality that the .NET Class Library provides is available to all .NET languages resulting in a consistent object model regardless of the programming language the developer uses. Simplified Development Efforts Let's take a look at Web applications. With classic ASP developer was required to mix the ASP code with the HTML code to get the desired result. ASP.NET and the .NET Framework simplify development by separating the application logic and presentation logic in different file. Easy Application Deployment and Maintenance The .NET Framework makes it easy to deploy applications. In the most common form, to install an application, all we need to copy the application along with the components it requires into a directory on the target computer. The .NET Framework handles the details of locating and loading the components an application needs, even if several versions of the same application exist on the target computer.
Architecture Of .Net Framework .Net framework has two tier architecture for running an application ,as follows The .NET Framework consists of two main components: Common Language Runtime (CLR) Class Libraries
Common Language Specification (CLS)
If we want the code which we write in a language to be used by programs in other languages then it should adhere to the Common Language Specification (CLS). The CLS describes a set of features that different languages have in common. The CLS defines the minimum standards that .NET language compilers must conform to, and ensures that any source code compiled by a .NET compiler can interoperate with the .NET Framework.
Namespaces A namespace is a collection of different classes. All .Net applications are developed using classes from the .NET System namespace. The namespace with all the built-in VB functionality is the System namespace. All other namespaces are based on this System namespace. ` Some Namespaces and their use: System: Includes essential classes and base classes for commonly used data types, events, exceptions and so on System.Collections: Includes classes and interfaces that define various collection of objects such as list, queues, hash tables, arrays, etc System.Data: Includes classes which lets us handle data from data sources System.Data.OleDb: Includes classes that support the OLEDB .NET provider System.Data.SqlClient: Includes classes that support the SQL Server .NET provider System.Diagnostics: Includes classes that allow to debug our application and to step through our code System.Drawing: Provides access to drawing methods System.Globalization: Includes classes that specify culture-related information System.IO: Includes classes for data access with Files System.Net: Provides interface to protocols used on the internet System.Reflection: Includes classes and interfaces that return information about types, methods and fields System.Security: Includes classes to support the structure of common language runtime security system System.Threading
: Includes classes and interfaces to support multithreaded applications System.Web: Includes classes and interfaces that support browser-server communication System.Web.Services: Includes classes that let us build and use Web Services System.Windows.Forms: Includes classes for creating Windows based forms System.XML: Includes classes for XML support
ASP.NET ASP.NET, the next version of ASP, is a programming framework used to create Web Applications. These applications are accessible over a network(internet). The advantages ASP.NET offers more than just the next version of ASP.
Why ASP.NET? Since 1995, Microsoft shift it's focus from Windows-based platforms to the Internet. As a result, Microsoft introduced ASP (Active Server Pages) in November 1996. But ASP Script was an interpreted script and contain unstructured code and was difficult to debug and maintain. As the web consists of many different technologies, software integration for Web development was complicated and required to understand many different technologies. Also, as applications grew bigger in size and became more complex, the number of lines of source code in ASP applications increased dramatically and was hard to maintain. Therefore, an architecture was needed that would allow development of Web applications in a structured and consistent way. The .NET Framework was introduced with a vision to create globally distributed software with Internet functionality and interoperability. The .NET Framework consists of many class libraries, includes multiple language support and a common execution platform. It's a very flexible foundation on which many different types of top class applications can be developed that do different things. Developing Internet applications with the .NET Framework is very easy. ASP.NET is built into this framework, we can create ASP.NET applications using any of the built-in languages. Unlike ASP, ASP.NET uses the Common Language Runtime (CLR) provided by the .NET Framework. This CLR manages execution of the code we write. ASP.NET code is a compiled CLR code instead of interpreted code (ASP). CLR also allows objects written in different languages to interact with each other. The CLR makes developement of Web applications simple.
Advantages Using ASP.NET ○ ASP.NET drastically reduces the amount of code required to build large applications ○ ASP.NET makes development simpler and easier to maintain with an event-driven, server-side programming model ○ ASP.NET pages are easy to write and maintain because the programming code and HTML are separated in different files.
○ The programming code is executed on the server. The pages have lots of power and flexibility by this approach ○ The programming code is compiled the first time the page is requested. Execution is fast as the web server compiles the page the first time it is requested. The server saves the compiled version of the page for use next time the page is requested ○ The HTML produced by the ASP.NET page is sent back to the browser. The application programming code you write is not sent and is not easily stolen ○ ASP.NET makes for easy deployment. There is no need to register components because the configuration information is built-in ○ ASP.NET validates information (validation controls) entered by the user without writing a single line of code ○ ASP.NET easily works with ADO .NET using data binding and page formatting features ○ ASP.NET applications run fsater and counters large volumes of users without performance problems
Web Server Web pages must be stored and organized in a central computer.Computer which store web pages in form of directories and files and provide these files to be read, are called “Server”. They act like a service providers that service the need for information. The server computer must runs special software called Web Server software that allow Web site Management. (1) Accept a client request for information. (2) Respond to client’s request by providing the page with the required information. Some of the most popular software which server run to allow them to respond to client request for information , are Internet Information Server, Apache Web Server , Netscape Server, Microsoft Personal Web Server.
IIS To develop a Web Application you need IIS (Internet Information Server) on your machine. IIS comes with Operating Systems like Windows 2000, XP and 2003. You need to configure IIS to run ASP.NET Web applications. You should configure IIS prior to the installation of Visual Studio .NET software on your machine to avoid errors. In most cases configuring IIS after the installation of VS .NET will result in many errors and unexpected behaviour by the application. By default, IIS creates a folder on the server's hard disk with the name Inetpub. The Inetpub folder contains a subfolder called wwwroot. The wwwroot folder is the root for the web site. All the ASP.NET applications you develop using VS .NET are saved in this wwwroot folder. ASP .Net Web controls are divided into five different groups. a. Basic Web Controls - Button, Checkboxes, CheckBoxList, DropDownList etc. b. Validation Web Controls - CompareValidator, CustomValidator, RangeValidator, RegularExpressionValidator, RequiredFieldValidator, Validation Summary
c. Data Controls - DataGrid , DataList, Repeater, d. Rich Web Controls e. Mobile Controls Benefits of Asp.Net Controls:
The folllowing are the benefits of Asp.net control.
1. An Intuitive Object Model 2. View State : The Difference b/w the simple HTML control and Asp.Net Control is that the Asp.Net control retains the values that are put into it after the post to the server.
HTML Server Controls HTML server controls are HTML tags understood by the server. HTML elements in ASP.NET files are, by default, treated as text. To make these elements programmable, add a runat="server" attribute to the HTML element. This attribute indicates that the element should be treated as a server control. The id attribute is added to identify the server control. The id reference can be used to manipulate the server control at run time. Note: All HTML server controls must be within a
To see currently active and selected item of a list control programmatically , we can look at its selectedvalue , seleteditem or selectedindex properties. Selectedvalue property return the string that contains the value for the selected item , like C# or visual Basic in the example. SelectedIndex return the zero based index of the item in the list.With example above if the user has choosen CSS the index would be 2. The BulletedList control does not allow a user to make selections , and as such does not support these properties. For control that support multiple selection (like CheckBoxList , and ListBox) , we can loop through the Items collection and see what items are seleted. In this case , seletedItem returns only the first seleted item in the list ; not all of them.
Properties ID---Programmatic name of the control. Accesskey----Keyboard shrot cut used by the control. BackColor----Set the backgrouhnd color of the control. BorderColor----Set the color of the border around control. BorderStyle-----Set the style of the border around control. BorderWidth-------Set the width of the border around control Enabled------------Enabled The state of the control. Enable Theming----Indicate whether control can be themed. EnableViewState-----Whether the control automatically saves its state for use in round trip. Font-----Font used for text within control. ForeColor-------Color of text within control Height-----The height of control TabIndex----The tab order of the control. Text-----The text to be show for the label. ToolTip--------The tooltip is displayed when the mouse is over the control. Visible---Indicate whether the control is visible or rendered. Width----The Width of the control. Text : Gets/Sets the text in a textbox
Events SelectedIndexChanged Occurs when the selection from the list control changes between posts to the server. (Inherited from ListControl.) TextChanged
Occurs when the Text and SelectedValue properties change. (Inherited from ListControl.)
Program 1:----- To get The Selected Item In the ListBox And Display them in label. Method 1.1 Dim item As ListItem For Each item In ListBox1.Items If item.Selected = True Then Label1.Text = Label1.Text & item.Value End If Next Method 1.2 Dim i As Integer For i = 0 To listbox1.items.count - 1 If listbox1.items(i).selected = True Then
label1.text = label1.text & listbox1.items(i) End If Next Program 2:--------- Program To Transffer All Item Of A List Box In Other ListBox Dim i As Integer For i = 0 To ListBox1.Items.Count - 1 ListBox2.Items.Add(ListBox1.Items(i)) Next Program 3:-------Program to Transffer Only selected item of a listbox to other Listbox Dim item As ListItem For Each item In ListBox1.Items If item.Selected = True Then ListBox2.Items.Add(item.Value) End If Next