Christopher M. Pascucci.NET Programming: Forms & Controls.

Slides:



Advertisements
Similar presentations
Tutorial 6 Creating a Web Form
Advertisements

JavaScript Forms Form Validation Cookies. What JavaScript can do  Control document appearance and content  Control the browser  Interact with user.
Video, audio, embed, iframe, HTML Form
Web Development Using ASP.NET CA – 240 Kashif Jalal Welcome to week – 3-1 of…
Introduction to ASP.Net ISYS 350. ASP.NET ASP.NET is a server-side technology for creating dynamic web pages. ASP.NET allows you to use a selection of.
XHTML Forms for Data Collection and Submission Chapter 5.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
ASP.NET Programming with C# and SQL Server First Edition
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
CST JavaScript Validating Form Data with JavaScript.
XP Tutorial 14 New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
Application Development Description and exemplification of server-side scripting language for server connection, database selection, execution of SQL queries.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
JavaScript & jQuery the missing manual Chapter 11
DR.JOHN ABRAHAM PROFESSOR UTPA ASP.NET. ACTIVE SERVER PAGES (ASP) Web application development environment Web applications use web browser to display.
Database-Driven Web Sites, Second Edition1 Chapter 8 Processing ASP.NET Web Forms and Working With Server Controls.
Module 7: Validating User Input.
Chapter 3 Using Validation Controls. What is a Validation Control? A control that validates the value in another control Renders as an HTML tag with an.
Server vs Client-side validation. JavaScript JavaScript is an object-based language. JavaScript is based on manipulating objects by modifying an object’s.
Dr. Azeddine Chikh IS444: Modern tools for applications development.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
CSCI 6962: Server-side Design and Programming Introduction to AJAX.
Telerik Software Academy ASP.NET Web Forms Data Validation, Data Validators, Validation Groups Telerik Software Academy
.Net is a collection of libraries, templates and services designed to make programming applications of all kinds, easier, more flexible (multi platform),
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
Christopher M. Pascucci.NET Programming: Basic ASPX Scripting & HTML Embedment.
ASP.Net Web Applications. Characteristics of a typical data driven web application Web Server HTML Graphics Active-X Java Applets HTTP Request ADO / JDBC.
1 VU. 2 CS101 Introduction to Computing Lecture 15 More on Interactive Forms (Web Development Lecture 5)
© 2000 – All Rights Reserved - Page 1 Introduction to JavaScript Programming Part Two.
Introduction to JavaScript + More on Interactive Forms.
JavaScript is a client-side scripting language. Programs run in the web browser on the client's computer. (PHP, in contrast, is a server-side scripting.
ASP.Net, Web Forms and Web Controls 1 Outline Web Controls Text and Graphics Controls AdRotator Control Validation Controls.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
© Minder Chen, ASP.NET 2.0: Introduction - 1 ASP.NET 2.0 Minder Chen, Ph.D. Framework Base Class Library ADO.NET: Data & XML.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
Lecture # 6 Forms, Widgets and Event Handling. Today Questions: From notes/reading/life? Share Personal Web Page (if not too personal) 1.Introduce: How.
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.
Using Client-Side Scripts to Enhance Web Applications 1.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
Active Server Pages  In this chapter, you will learn:  How browsers and servers interacted on the Internet when the Internet first became popular 
Introduction to HTML Part 3 Chapter 2. Learning Outcomes Identify how to design frames. Explain frames’ attributes. Describe the method on designing forms.
Web App GUI: JSP Basics & Forms 3680 Enterprise Programming.
HTML Form Widgets. Review: HTML Forms HTML forms are used to create web pages that accept user input Forms allow the user to communicate information back.
Introduction to JavaScript CS101 Introduction to Computing.
HTML Forms. Slide 2 Forms (Introduction) The purpose of input forms Organizing forms with a and Using different element types to get user input A brief.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Bookstore Application: Middle Tier Introducing Code-Behind Files, Session State.
ASP.NET 4 Unleashed Chapter 1. .aspx page: contains C# script and HTML code including tags. Listing 1.1 FirstPage.aspx.
Christopher M. Pascucci.NET Programming: WebForm Events.
 Previous lessons have focused on client-side scripts  Programs embedded in the page’s HTML code  Can also execute scripts on the server  Server-side.
©SoftMooreSlide 1 Introduction to HTML: Forms ©SoftMooreSlide 2 Forms Forms provide a simple mechanism for collecting user data and submitting it to.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Javascript JavaScript is what is called a client-side scripting language:  a programming language that runs inside an Internet browser (a browser is also.
Creating Web Page Forms COE 201- Computer Proficiency.
XP Tutorial 7 New Perspectives on JavaScript, Comprehensive 1 Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
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.
PostBack  When an initial request for a page (a Web Form) is received by ASP.NET, it locates and loads the requested Web Form (and if necessary compiles.
 ASP.NET provides an event based programming model that simplifies web programming  All GUI applications are incomplete without enabling actions  These.
Tutorial 6 Creating a Web Form
HTML Tutorial. What is HTML HTML is a markup language for describing web documents (web pages) HTML documents are described by HTML tags Each HTML tag.
Unit 4 Working with data. Form Element HTML forms are used to pass data to a server. A form can contain input elements like text fields, checkboxes, radio-buttons,
Ashima Wadhwa Java Script And Forms. Introduction Forms: –One of the most common Web page elements used with JavaScript –Typical forms you may encounter.
Client-side (JavaScript) Validation. Associating a function with a click event – Part 1 Use the input tag’s onclick attribute to associate a function.
A little PHP. Enter the simple HTML code seen below.
Chapter 5 Validating Form Data with JavaScript
Computing with C# and the .NET Framework
In this session, you will learn to:
Forms, cont’d.
PART 2.
Web Development Using ASP .NET
Presentation transcript:

Christopher M. Pascucci.NET Programming: Forms & Controls

Web Forms  Forms are the means by which a user can transmit data to the server from the browser.  A form is populated with one or more elements that are called controls.  Examples are the textbox, dropdown, radio button, checkbox, and buttons.  Transmitting data to the server from the client/browser involves 2 concepts: 1.First is that of controls, which allows the user to enter information, make selections and indicate that data is to be transmitted. 2.Second are events, which occur during some action (clicking a button) and allow a particular control to connect itself to a function, either on the client-side or server-side.  ASP.NET introduces a different set of form controls, called Web Form Controls (WFC). The original html form elements are called HTML Form Controls (HFC).  HFC Example:  WFC Example:

Web Forms & Controls  An aspx page can only contain ONE control…!  All server controls must appear within a tag, and the tag must contain 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.  An HFC can be converted to exhibit the behavior of a WFC by adding the runat="server" attribute to its HTML control tag.   ***Only HFCs are subject to being intercepted on the client-side for script processing, such as one would want to do for validation.  WFCs or an HFC that has been converted like the above will submit the form and by pass any possibility of doing any client-side processing.  The client side script can access the content of either an HFC or WFC control.

Client-Side Processing 1.Intercepting a button for function processing.  To intercept a form button with a client script function, the button must be an HTML form control (HFC). It can be done in either of the following ways:  You can use a button with type=“button” attribute of the Input tag and call a client-side script function or the click event of the button.  The form action can be invoked within the client script function by the statement formName.submit(), as shown in the code snippet.  If you wish to change the action, you can do it in the function with the statement formName.action = “newURL”, but only if the URL refers to a page that is.htm or.asp.  Transferring to an aspx page from the client script will result in a viewstate error. Aspx transfers can be made in the client script function using the statement window.location.href =”newURL”. Alternatively, aspx transfers can be made on the server-side using either a response.redirect or an application.transfer. Sub myClientProcess() … formName.submit() end Sub OR Sub btnClient_onclick() … formName.submit() end Sub <Input name=”btnClient” type=”button”

Client-Side Processing 2.Referencing the controls from client-side script.  Either type of control (HFC or WFC) can be referenced for processing within a client script function. This is the means by which one can validate data contained in the control.  The control is referenced as formName.controlName.value. Sub checkForm() If MyForm.txtName.value = “” Then msgbox(“Name cannot be blank!”) Else MyForm.submit() End If End Sub

Server-Side Processing 1.Accessing data from an HFC.  To access an html form control on the server side, use request("controlName") in the aspx page.  To write data back to a web page use response.write(textVariable) or the shorthand format 2.Accessing data from a WFC or HFC with runat=“server”.  To reference any runat="server" control on the server side, whether it is an HFC or WFC, simply use its object name with an appropriate property.  An HFC control is referenced as ctlName.value, and a WFC control is referenced as controlName.text.  The following table summarizes the above cases for access of controls on both the client and server sides, the method is given for ctlName.method SideWeb Form ControlHTML Form Control (runat=“server”) HTML Form Control (run on client) Client.value Server.text.valueRequest(“ControlName”)

Server-Side Processing 3.Activating a function on the server-side from a button control with runat=“server. With a CodeBehind a)You can double click on the button control in design mode. It will automatically create a Private function in the Code Behind named controlName_Click with phrase Handles controlName.Click afterward. b)You can place an attribute OnClick="functionName()" in the button's tag, it will call a function Public functionName() in the codeBehind, when the button is clicked. You do not need the Handles btnResetTable.Click phrase. Without a CodeBehind c)Code in script tag Sub Answer_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) [Insert code of the Sub] End Sub

More on HTML Controls  The expression Request("controlName") accesses the data in the control named controlName on the server-side from the form that was submitted on the client side.  This can be used in the ASPX page as script or in the Code Behind.  If no control with the name controlName has been submitted, then "" (blank string) is returned. This can happen in the following circumstances:  No such name exists on the form.  If all checkboxes or radio buttons with that name are unchecked.  If a textbox with that name has "“ (empty string) in it.  For more info on Form controls refer to the class website page on Forms & ControlsForms & Controls Demo Code of ASPX page