Development of Internet Application 1501CT - Sara Almudauh

Slides:



Advertisements
Similar presentations
WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
Advertisements

IT533 Lecture ASP.NET Controls. Installations Microsoft® SQL Server® 2008 Express.
Asp.NET Core Server Controls. Slide 2 Lecture Overview Understanding the types of ASP.NET controls HTML controls ASP.NET (Web) controls.
Creating Web Page Forms. Objectives Describe how Web forms can interact with a server-based program Insert a form into a Web page Create and format a.
Web Development Using ASP.NET CA – 240 Kashif Jalal Welcome to week – 3-1 of…
ASP.NET Programming with C# and SQL Server First Edition
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Beginning Active Server Pages Barry Sosinsky Valda Hilley Programming.
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
Database-Driven Web Sites, Second Edition1 Chapter 8 Processing ASP.NET Web Forms and Working With Server Controls.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used.
Overview of Previous Lesson(s) Over View  Server controls are small building blocks of the graphical user interface, which includes  Text boxes  Buttons.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
Programming with Microsoft Visual Basic 2012 Chapter 12: Web Applications.
ASP.Net Web Applications. Characteristics of a typical data driven web application Web Server HTML Graphics Active-X Java Applets HTTP Request ADO / JDBC.
Web Development Using ASP.NET CA – 240 Kashif Jalal Welcome to week – 4-1 of…
ASP.NET Web Application and Development Digital Media Department Unit Credit Value : 4 Essential Learning time : 120 hours Digital.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
ASP.NET Web Server Controls Basic Web Server Controls.
Chapter 4 – Working with ASP.NET Controls Dr. Stephanos Mavromoustakos.
ASP.NET Controls. Slide 2 Lecture Overview Identify the types of controls supported by ASP.NET and the differences between them.
Microsoft Visual Basic 2008 CHAPTER SEVEN Creating Web Applications.
Tutorial 7 Creating Forms. Objectives Session 7.1 – Create an HTML form – Insert fields for text – Add labels for form elements – Create radio buttons.
Microsoft Visual Basic 2005 CHAPTER 7 Creating Web Applications.
1 CS 3870/CS 5870 Note04 Session Variables and Post Back.
1 Chapter 12 – Web Applications 12.1 Programming for the Web, Part I 12.2 Programming for the Web, Part II 12.3 Using Databases in Web Programs.
HTML Forms.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Unit 2 : Creating a Microsoft ASP.NET Web Form.
Module 4: Creating a Microsoft ASP.NET Web Form. Overview Creating Web Forms Using Server Controls.
Session 4: HTML and Web Server Controls. Outline Creating Web Forms Using Server Controls HTML Server Controls Web Server Controls Writing ASP Code Inline.
ASP. What is ASP? ASP stands for Active Server Pages ASP is a Microsoft Technology ASP is a program that runs inside IIS IIS stands for Internet Information.
Lecture Note 7: Sessions and Applications Object.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
CIS 375—Web App Dev II ASP.NET 4 Server Controls.
Overview of Previous Lesson(s) Over View  ASP is a technology that enables scripts in web pages to be executed by an Internet server.  ASP.NET is a.
11 Getting Started with ASP.NET Beginning ASP.NET in C# and VB Chapters 1 and 2.
Active Server Pages Session - 3. Response Request ApplicationObjectContext Server Session Error ASP Objects.
HTML Structure II (Form) WEEK 2.2. Contents Table Form.
ASP.NET Part 2 Instructor: Charles Moen CSCI/CINF 4230.
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
Lecture 6 Sara Almudauh ASP.NET Part 1 Development of Internet Application 1501CT - Sara Almudauh.
Tutorial 6 Working with Web Forms
Computing with C# and the .NET Framework
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
ASP.NET Forms.
Working with ASP.NET Server Controls
Y.-H. Chen International College Ming-Chuan University Fall, 2004
ASP.NET Web Controls.
3.01 Apply Controls Associated With Visual Studio Form
Basic XHTML Tables XHTML tables—a frequently used feature that organizes data into rows and columns. Tables are defined with the table element. Table.
3.01 Apply Controls Associated With Visual Studio Form
Development of Internet Application 1501CT - Sara Almudauh
Creating Web Applications
Unit 27 - Web Server Scripting
Client side & Server side scripting
FORM OBJECT When creating an interactive web site for the Internet it is necessary to capture user input and process this input. Based on the result of.
Forms, cont’d.
12/9/2018 Session 9.1 Calendar and Validation Controls Using Sessions
CNIT 131 HTML5 - Forms.
Static and Dynamic Web Pages
Building ASP.NET Applications
ASP.NET.
Module 05: Building ASP .NET Applications
Web Development Using ASP .NET
Creating Session By huda AlSuwailem.
Cookies A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each time the same computer.
PHP-II.
Programming with Microsoft Visual Basic 2008 Fourth Edition
Button Web Server Controls
Presentation transcript:

Development of Internet Application 1501CT - Sara Almudauh ASP.NET Part 2 Lecture 7 Sara Almudauh Development of Internet Application 1501CT - Sara Almudauh

What is ASP.NET Server Control? ASP.NET server controls The simplest ASP.NET components Wrap an HTML UI element, or more complex UI Component-oriented programming model Executed and rendered at the server side Example of ASP.NET server controls: <asp:Button>  <input type=“submit”> <asp:Label>  <span> <asp:GridView>  <table><tr><td>.. Development of Internet Application 1501CT - Sara Almudauh

ASP.NET - Server Controls Server controls are tags that are understood by the server. There are three kinds of server controls: HTML Server Controls - Traditional HTML tags. Web Server Controls - New ASP.NET tags: Basic Web Controls . Validation Controls . List Controls . Rich Controls. Development of Internet Application 1501CT - Sara Almudauh

The runat Attribute The runat attribute makes a server control a server control This is true for both HTML and Web controls All tags without the runat attribute are copied verbatim to the output stream (HTTP response) <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>

Development of Internet Application 1501CT - Sara Almudauh 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. Development of Internet Application 1501CT - Sara Almudauh

HTML Controls Supported controls <a> <img> <form> <table> <tr> <td> <th> <select> <textarea> <button> <input type=text> <input type=file> <input type=submit> <input type=button> <input type=reset> <input type=hidden>

Development of Internet Application 1501CT - Sara Almudauh HTML Server Controls All HTML server controls must be within a <form> tag with the runat="server" attribute. The runat="server" attribute indicates that the form should be processed on the server. It also indicates that the enclosed controls can be accessed by server scripts. Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh EXAMPLE <head> <title> Html Server Control</title> </head> <body> <form id=“FormMain” runat=“server”> <input id=“TextField” type=“text” runat=“server> <input id=“ButtonSubmit” type=“button” runat=“server value=“submit”> </form> </body> Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh Web Server Controls Web server controls are special ASP.NET tags understood by the server. Like HTML server controls, Web server controls are also created on the server and they require a runat="server" attribute to work. The syntax for creating a Web server control is: <asp:control_name id="some_id" runat="server" /> Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh EXAMPLE <script runat="server"> Sub submit(Source As Object, e As EventArgs) button1.Text="You clicked me!" End Sub </script> <html> <body> <form runat="server"> <asp:Button id="button1" Text="Click me!" runat="server" OnClick="submit"/> </form> </body> </html> Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh Web Server Controls Web Controls provide extensive properties to control display and format, e.g. Font BackColor, ForeColor BorderColor, BorderStyle, BorderWidth Style, CssClass Height, Width Visible, Enabled Development of Internet Application 1501CT - Sara Almudauh

Web Controls Example Image control RadioButtonList TextBox control DropDownList control HyperLink control RadioButtonList Button control

Development of Internet Application 1501CT - Sara Almudauh Basic Web Controls Development of Internet Application 1501CT - Sara Almudauh

Validation Server Controls Validation server controls are used to validate user-input. If the user-input does not pass validation, it will display an error message to the user. Each validation control performs a specific type of validation (like validating against a specific value or a range of values). By default, page validation is performed when a Button, ImageButton, or LinkButton control is clicked. Types of user errors: Forget to fill an important field Submitting the wrong type of data Submitting the data in a wrong format Development of Internet Application 1501CT - Sara Almudauh

Validation Server Controls Most important validation controls: RequiredFieldValidator RangeValidator CompareValidator RegularExpressionValidator ValidationSummary Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh EXAMPLE <html> <body> <form runat="server"> <p>Enter a number from 1 to 100: <asp:TextBox id="tbox1" runat="server" /> <br /><br /> <asp:Button Text="Submit" runat="server" /> </p> <p> <asp:RangeValidator ControlToValidate="tbox1" MinimumValue="1" MaximumValue="100" Type="Integer" Text="The value must be from 1 to 100!" runat="server" /> </p></form></body></html> Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh List Controls ListBox CheckBoxList RadioButtonList BulletedList Repeater DataList GridView DropDownList ListView Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh Rich Controls Task-specific controls Built with multiple HTML elements Rich functionality Examples: Calendar Menu Development of Internet Application 1501CT - Sara Almudauh

ASP.NET Server Controls (Event Wiring 1) ASP.NET Server controls have support events similar to their desktop countertops Names Match

ASP Object: Cookies A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. It is a small piece of data sent from a website and stored in a user's web browser while the user is browsing that website. Every time the user loads the website, the browser sends the cookie back to the server to notify the website of the user's previous activity

Cookies With ASP, you can both create and retrieve cookie values. The "Response.Cookies" command is used to create cookies. The Response.Cookies command must appear BEFORE the <html> tag. <% Response.Cookies("firstname")="Alex" %>

Development of Internet Application 1501CT - Sara Almudauh If a cookie contains a collection of multiple values, we say that the cookie has Keys. In the example below, we will create a cookie collection named "user". The "user" cookie has Keys that contains information about a user: <% Response.Cookies("user")("firstname")="John" Response.Cookies("user")("lastname")="Smith" Response.Cookies("user")("country")="Norway" Response.Cookies("user")("age")="25" %> Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh Read all Cookies Assume that your server has sent all the cookies above to a user. Now we want to read all the cookies sent to a user. The example below shows how to do it (note that the code below checks if a cookie has Keys with the HasKeys property): Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh <!DOCTYPE html> <html> <body> <% dim x,y for each x in Request.Cookies   response.write("<p>")   if Request.Cookies(x).HasKeys then     for each y in Request.Cookies(x)       response.write(x & ":" & y & "=" & Request.Cookies(x)(y))       response.write("<br>")     next   else     Response.Write(x & "=" & Request.Cookies(x) & "<br>")   end if   response.write "</p>" next %> </body> </html> Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh output firstname=Alex user:firstname=John user:lastname=Smith user:country=Norway user:age=25 Development of Internet Application 1501CT - Sara Almudauh

ASP Object: Session A Session object stores information about, or change settings for a user session. Variables stored in a Session object hold information about one single user, and are available to all pages in one application. Common information stored in session variables are name, id, and preferences. The server creates a new Session object for each new user, and destroys the Session object when the session expires.

Development of Internet Application 1501CT - Sara Almudauh A session starts when: A new user requests an ASP file, and the Global.asa file includes a Session_OnStart procedure A value is stored in a Session variable A user requests an ASP file, and the Global.asa file uses the <object> tag to instantiate an object with session scope Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh A session ends if a user has not requested or refreshed a page in the application for a specified period. By default, this is 20 minutes. If you want to set a timeout interval that is shorter or longer than the default, use the Timeout property. The example below sets a timeout interval of 5 minutes <% Session.Timeout=5 %> Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh Use the Abandon method to end a session immediately: <% Session.Abandon %> Development of Internet Application 1501CT - Sara Almudauh

Store and Retrieve Session Variables The most important thing about the Session object is that you can store variables in it. The example below will set the Session variable username to "Donald Duck" and the Session variable age to "50": <% Session("username")="Donald Duck" Session("age")=50 %> Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh When the value is stored in a session variable it can be reached from ANY page in the ASP application: Welcome <%Response.Write(Session("username"))%> The line above returns: "Welcome Donald Duck". Development of Internet Application 1501CT - Sara Almudauh

Remove Session Variables The Contents collection contains all session variables. It is possible to remove a session variable with the Remove method. The example below removes the session variable "sale" if the value of the session variable "age" is lower than 18: <% If Session.Contents("age")<18 then   Session.Contents.Remove("sale") End If %> To remove all variables in a session, use the RemoveAll method: <% Session.Contents.RemoveAll() %> Development of Internet Application 1501CT - Sara Almudauh

Loop Through the Contents Collection <% Session("username")="Donald Duck" Session("age")=50 dim i For Each i in Session.Contents   Response.Write(i & "<br>") Next %> output: username age Development of Internet Application 1501CT - Sara Almudauh

Count property: Number of variables in session <% dim i dim j j=Session.Contents.Count Response.Write("Session variables: " & j) For i=1 to j   Response.Write(Session.Contents(i) & "<br>") Next %> Development of Internet Application 1501CT - Sara Almudauh

To add the new Global Application Class to your project: right click the project entry in Solution Explorer. choose Add New Item from the context menu. You’ll see an Add New Item dialog box. Select Global Application Class from the template list.

A Global Application Class contain five functions 1- Application_Start : This function contains the Code that runs on application startup. 2- Application_End: This function contains the Code that runs on application shutdown. 3- Application_Error : This function contains the Code that runs when an unhandled error occurs. 4- Session_Start : This function contains the Code that runs when a new session is started. 5- Session_End : This function contains the Code that runs when a session ends.

If you want to initialize the values of variables that you will use in the session, do this:

For example:

This will appear after entering the previous data and clicking on the registration button.

Creating an ASP.NET Web Application using Visual Studio Step 1: Creating the Web Application Project Select File > New Web Site... and choose ASP.NET Empty Web Site in the Templates pane. Select File System from the drop-down list closest to Location. Set the Language to Visual Basic, and click OK.

Creating an ASP.NET Web Application using Visual Studio To add new page or web form to : Right click in your website then select new item > Web form. Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh Questions !!  Development of Internet Application 1501CT - Sara Almudauh