1 / 26


ASP .NET. ASP.NET Environment. ASP.NET is Microsoft's programming framework that enables the development of Web applications and services. It is an easy and scalable way to build, deploy, and run Web applications that can target any browser or device.

Télécharger la présentation


An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.


Presentation Transcript

  1. ASP.NET .

  2. ASP.NET Environment • ASP.NET is Microsoft's programming framework that enables the development of Web applications and services. • It is an easy and scalable way to build, deploy, and run Web applications that can target any browser or device. • ASP.NET pages work in all browsers -- Navigator, Opera, AOL, Internet Explorer, and others.

  3. ASP.NET Environment • Many of the functionalites take place in the background, their details hidden from view of, and usually hidden from concern by, the programmer. • ASP.NET has a rich set of objects to work with in an object-oriented and compiled programming environment.

  4. ASP.NET Environment • The programming environment supports more than 25 .NET languages, including built-in support for VB.NET, C#, and JScript.NET. • .NET Framework offers over 4500 software classes that encapsulate rich functionality like XML, data access, file upload, regular expressions, image generation, performance monitoring and logging, transactions, SMTP mail, and much more.

  5. ASP.NET Environment • These classes provide an extensive set of objects, properties, and methods accessible through Visual Basic for enhancing your Web applications. • Though code is compiled, ASP.NET automatically detects any code changes, dynamically compiles the files if needed, and stores the compiled results for reuse in subsequent requests.

  6. ASP.NET Environment • Dynamic compilation ensures that applications are up to date, and compiled execution makes them fast. There is a short delay when a page is first accessed and compiled. Subsequent accesses, though, retrieve the compiled, cached version of the page for immediate execution.

  7. ASP.NET Environment • The ASP.NET framework is backward compatible. It runs classic ASP pages just as before, permitting integration of new capabilities as they are learned. ASP.NET pages have a new file extension, .aspx, to differentiate them from standard ASP pages. When this new extension is detected, the ASP.NET processor handles the page request.

  8. ASP.NET Environment • User interaction under ASP.NET, is through a Web browser. New Web Form controls in ASP.NET replace many of the standard HTML tags.

  9. ASP.NET Page Structure • ASP.NET pages are transmitted to the Web server in order to process data and generate information. Normally, this request is triggered by some user action on the local PC. For instance, the user enters data into a form and then clicks a button. The button click causes the form to be transmitted to the server where processing routines massage the data and produce output. Output usually is embedded on the Web page prior to its return to the user.

  10. ASP.NET Page Structure • Web page processing takes place on the server. Data are collected on the local PC, shipped to the server for processing, with results returned to the local PC as a reformulated or reformatted page displaying processing results.

  11. ASP.NET Page Structure

  12. Web Application C# • <%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true“ CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %> • <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent“> </asp:Content> • <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> • <h2> Welcome to ASP.NET! </h2> • <p> To learn more about ASP.NET visit <a href="" title="ASP.NET Website"></a>. </p> • <p> You can also find <a href=;clcid=0x409 title="MSDN ASP.NET Docs">documentation on ASP.NET at MSDN</a>. • </p></asp:Content>

  13. ASP.NET Page Structure • The SCRIPT portion of the page, normally coded at the top of the page, contains server code to process data. That data can be supplied by the user through a form, extracted from files or databases, and/or generated internally by the script. The script contains processing commands, or statements which are encapsulated within named subroutines, or subprograms, that are called upon to perform their processing.

  14. ASP.NET Page Structure • The HTML portion of the page serves two functions. It captures input data for transmission to the server, and it displays output results from server processing. • These two functions take place through Web Forms containing various server controls, special form elements that permit data input, output display, and requests for script processing.

  15. ASP.NET Page Structure • Together, Web Forms and server scripts encapsulate on a single page all the functionality needed to turn Web pages into full-featured information processors. • It is common for ASP.NET pages to supply three types of HTML form controls to effect information processing.

  16. ASP.NET Page Structure • A "data input control" is needed to supply data for processing • A "script activation control" is needed to call upon scripts to process the data • An "output control" is required to identify an area on the page where script output can appear.

  17. ASP.NET Ex1.aspx • <asp:TextBox id="MyInput" runat="server"></asp:TextBox> • <asp:Button id="Button1" onclick="Display_Output" runat="server" Text="Click Me"/> • <asp:Label id="MyOutput" runat="server"/>

  18. ASP.NET Ex1.aspx • A textbox control accepts input data from the user, a button calls a script to process the data, and an output control provides the target area for script output.

  19. ASP.NET Ex1.aspx • In this case the subprogram simply takes the value entered into the TextBox and writes it, along with other enclosing strings of text, to the Label control. • Note that the script, the controls, and their enclosing <form> tag contain the attribute runat="server". This specification indicates that all of these page elements participate in script processing on the server.

  20. ASP.NET Ex1.aspx • In this example an <asp:TextBox> control supplies the input box. An <asp:Button> control calls a script subroutine named Display_Output when clicked. An <asp:Label> control serves as an area on the page to which the script writes its output. Both the TextBox and Label controls are given id values so that the script can refer to them when performing its processing.

  21. ASP.NET Ex1.aspx • <script runat="server"> • protected void Display_Output(object sender, EventArgs e) • { • MyOutput.Text = "Welcome, " + MyInput.Text; • MyInput.Visible=false; • Button1.Visible=false; }</script>

  22. ASP.NET Ex1.aspx • The script appearing at the top of the page contains the subroutine named Display_Output. The associated list of arguments contained within parentheses (object sender, EventArgs e) are references to the particular server control which calls the subroutine -- the button in this case.

  23. ASP.NET Ex1.aspx • “Object sender” parameter is a reference to the source of the subroutine call -- the button itself; the e (EventArgs) parameter is a pointer to any data values associated with the button -- none in this example. These are standard arguments that must be supplied when a button calls a subprogram.

  24. ASP.NET Ex1.aspx • The button click triggers a form submission which transmits the controls and their values to the Web server. At the same time, a URL request is made of the server to retrieve a new copy of this same Web page from its storage directory on the server and to make available to this page the transmitted values. The button click also indicates that when the page is retrieved the subprogram named Display_Output is to be run.

  25. ASP.NET Ex1.aspx • This subprogram copies the transmitted data from the Textbox into the Label area, embedding it within the other text and HTML on the page. Following script processing this reformulated page is returned from the server to your PC, with your name appearing on the page.

  26. ASP.NET Ex2.aspx • Ex1.aspx can be changed to hide the textbox and button after user clicks the button. • We will use “visible” property of the object and set it to “false” in order to hide it. • “id” will be used as object name. • If “id” is “MyInput” then property can be set as: • MyInput.visible=false

More Related