Chapter 4 – Working with ASP.NET Controls Dr. Stephanos Mavromoustakos.

Slides:



Advertisements
Similar presentations
Working with Tables for Page Design – Lesson 41 Working with Tables for Page Design Lesson 4.
Advertisements

Chapter 3 – Designing your web pages Dr. Stephanos Mavromoustakos.
Introduction to Microsoft Excel 2010 Chapter Extension 3.
EXCEL Spreadsheet Basics
Word Processing First Steps
IT533 Lecture ASP.NET Controls. Installations Microsoft® SQL Server® 2008 Express.
Intermediate Level Course. Text Format The text styles, bold, italics, underlining, superscript and subscript, can be easily added to selected text. Text.
Asp.NET Core Server Controls. Slide 2 Lecture Overview Understanding the types of ASP.NET controls HTML controls ASP.NET (Web) controls.
Introducing Cascading Style Sheets  Cascading Style Sheet Basics  Creating Styles  Using Styles  Manipulating Styles  Text Formatting with CSS.
Web Development Using ASP.NET CA – 240 Kashif Jalal Welcome to week – 3-1 of…
Create a Form in Dreamweaver Go to: Introduction Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 Introduction Goals Purpose Scope Prerequisites Install (if needed)
Creating Tables in a Web Site Using an External Style Sheet HTML5 & CSS 7 th Edition.
With Alex Conger – President of Webmajik.com FrontPage 2002 Level I (Intro & Training) FrontPage 2002 Level I (Intro & Training)
Chapter 9 Collecting Data with Forms. A form on a web page consists of form objects such as text boxes or radio buttons into which users type information.
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
Lesson 11: Maximizing Site Design Introduction to Adobe Dreamweaver CS6 Adobe Certified Associate: Web Communication using Adobe Dreamweaver CS6.
Lesson 13: Building Web Forms Introduction to Adobe Dreamweaver CS6 Adobe Certified Associate: Web Communication using Adobe Dreamweaver CS6.
HTML Concepts and Techniques Fourth Edition Project 8 Creating Style Sheets.
Chapter 3 Working with Text and Cascading Style Sheets.
Copyright © Texas Education Agency, All rights reserved. 1 Web Technologies Website Development with Dreamweaver.
HTML, Third Edition--Illustrated Introductory 1 HTML, Third Edition Illustrated Introductory Unit F Working with Tables.
CITY UNIVERSITY / Vysoká Škola Manažmentu.:MG Information Systems :. © Martina Cesalova, 2005 MS FRONTPAGE 1 1.Open FrontPage – View -> Page 2.Open.
Database-Driven Web Sites, Second Edition1 Chapter 8 Processing ASP.NET Web Forms and Working With Server Controls.
1 Web-Enabled Decision Support Systems Introduction to ASP.NET Prof. Name Position (123) University Name.
Working with a Database
© Ms. Masihi.  The Dreamweaver Welcome Screen first opens when you start Dreamweaver.  This screen gives you quick access to previously opened files,
Web Technologies Website Development Trade & Industrial Education
Forms. 2 Project Objectives Discuss form processing Describe the difference between client-side and server-side form processing Add a horizontal rule.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
Website Development with Dreamweaver
ASP.NET Web Server Controls Basic Web Server Controls.
Microsoft Word 2000 Presentation 5. Major Word Topics Columns Tables Lists.
Microsoft Expression Web-Illustrated Unit I: Working with Tables.
Adobe Dreamweaver CS3 Revealed CHAPTER FIVE: USING HTML TABLES TO LAY OUT A PAGE.
Chapter 6 Generating Form Letters, Mailing Labels, and a Directory
Microsoft Visual Basic 2008 CHAPTER SEVEN Creating Web Applications.
CSCI 6962: Server-side Design and Programming Introduction to Active Server Pages.
Tutorial 7 Creating Forms. Objectives Session 7.1 – Create an HTML form – Insert fields for text – Add labels for form elements – Create radio buttons.
Fall 2005 Using FrontPage to Enhance Blackboard - Darek Sady1 Using FrontPage to Enhance Blackboard 1.Introduction 2.Starting FrontPage 3.Creating Documents.
Macromedia Dreamweaver 8-- Illustrated Introductory 1 Macromedia Dreamweaver 8 Unit D Formatting Text and Using Cascading Style Sheets.
Microsoft Visual Basic 2005 CHAPTER 7 Creating Web Applications.
Chapter 8 Collecting Data with Forms. Chapter 8 Lessons Introduction 1.Plan and create a form 2.Edit and format a form 3.Work with form objects 4.Test.
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.
XP Practical OpenOffice.org Chapter 8 1 Creating a Presentation.
Sports Website Creation. In this project you will design and produce your own website.
Layers, Image Maps, and Navigation Bars
1 Building FORMS In When a visitor enters information into a web form displayed in a web browser and clicks the submit button, the information is sent.
Chapter 4: Working with ASP.NET Server Controls OUTLINE  What ASP.NET Server Controls are  How the ASP.NET run time processes the server controls on.
Introducing Cascading Style Sheets. Cascading Style Sheet Basics  Cascading Style Sheet Basics  Creating Styles  Using Styles  Manipulating Styles.
HTML Concepts and Techniques Fifth Edition Chapter 4 Creating Tables in a Web Site.
Editing Basics Lesson 8. Skills Matrix SKILL #MATRIX SKILL 2.2.1Cut, copy, and paste text 2.2.2Find and replace text 4.1.1Insert building blocks in documents.
Photoshop Image Slicing. Reasons to Image Slide To create links out of sliced images To optimise different areas. (flat areas of colour, such as logos,
Chapter 3 Automating Your Work. It is frustrating when you have to type the same passage of text repeatedly. For example your name and address. Word includes.
20-753: Fundamentals of Web Programming 1 Lecture 6: Advanced HTML Fundamentals of Web Programming Lecture 6: Advanced HTML.
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
Building a Website: Layout Fall Overall Structure: Home Page Title Section Title Frame Picture UNCP Math Menu Content Footer Contact Information.
Chapter 28. Copyright 2003, Paradigm Publishing Inc. CHAPTER 28 BACKNEXTEND 28-2 LINKS TO OBJECTIVES Table Calculations Table Properties Fields in a Table.
How to make a Jeopardy type game in PowerPoint. Open a blank PowerPoint.
Word and the Writing Process. To create a document 1.On the Start menu, point to Programs, and then click Microsoft Word. A new document opens in Normal.
CREATING MASTER PAGES Creating a Master Page Using Master Pages Giving your site a professional look and feel Adding Master Page content to existing pages.
Chapter 7 Creating Templates, Importing Data, and Working with SmartArt, Images, and Screen Shots Microsoft Excel 2013.
ASP.NET Web Controls.
With Microsoft FrontPage 2000
ASP.NET Web Controls.
Microsoft Excel.
Word and the Writing Process
Unit I: Collecting Data with Forms
Unit 27 - Web Server Scripting
Web Development Using ASP .NET
Programming with Microsoft Visual Basic 2008 Fourth Edition
Presentation transcript:

Chapter 4 – Working with ASP.NET Controls Dr. Stephanos Mavromoustakos

Introduction to Server Controls Server controls “live” on the server inside an ASPX page. Instead of defining HTML controls in your pages directly, you define an ASP.NET Server Control with the following syntax where the italic parts differ for each control (e.g. creating a TextBox that can hold the same welcome message and current time)

Introduction to Server Controls Open your project In the Demos folder create a new Web Form called ControlsDemo.aspx. Switch to Design View. Drag a TextBox, a Button, and a Label control onto the design surface within the dashed lines of the tag that was added for you Type the text Your Name in front of the TextBox and add a line break between the Button and the Label by positioning your cursor between the two controls in Design View and then pressing Enter or place your cursor after the label and then press the left arrow key twice.

Introduction to Server Controls Your Design View should look like this:

Introduction to Server Controls Right-click the Button and in the Properties set the control’s text property to Submit and set its ID (found at the bottom of the of the list) to btnSubmit Change the ID of the TextBox to txtName using the Properties Grid. Clear the Text property of the Label1 using the Properties. You can leave its ID set to Label1. Double-click the button to add the code between the “Protected” and the “End Sub”: Label1.Text = "Your Name is " & txtName.Text

Introduction to Server Controls Save the changes to the page and press Ctrl F5 to open it in the browser. Fill in your name in the text box, and then click the button Right-click your page to see the HTML code Note: Some properties can only be set programmatically and not with the Properties Grid.

Common Properties for All Controls ID – uniquely identifies the control Runat – always set to Server ClientID – contains the client-side ID attribute that will be assigned to the element in the final HTML BackColor/ ForeColor – change the color of the background and text of the control in the browser Font – Define different font-related settings Height/Width – Determines the height and width of the control in the browser Visible – Determines whether the control is sent to the browser or not.

CSS and Controls As learned previously, avoid inline styles and opt for external CSS instead (for readability, reusability, and maintenance) such as: And the following CSS class:

CSS and Controls.TextBox { color: White; background-color: Black; border-color: Blue; border-width: 4px; border-style: Dashed; font-size: 30px; height: 40px; width: 200px; }

List Controls Open your project and in the Demos folder, create a new Web Form called ListControls.aspx. Switch to Design View and then drag a DropDownList within the element. The pop-up menu that appears is called the Smart Tasks panel or menu. There are 3 options: 1 – bind the control to a data source 2- add items to the list manually 3 – sets the AutoPostBack property. If this is checked, the control will submit the page it’s contained in back to the server as soon as the user chooses a new item from the list The Smart Tasks panel appears only for the more complex controls. To reopen the Smart Tasks panel, right-click the control and choose Show Smart Tag (or click the little arrow at the top-right corner of the control)

List Controls Click the Edit Items link Click the Add button. In the Properties Grid on the right, enter C# for the Text property and then press Tab. Repeat twice adding to your list items for Visual Basic and CSS. Click OK. Your code should be: C# Visual Basic CSS

List Controls Switch to Source View if necessary, and then drag a CheckBoxList control directly in the code window, right after the DropDownList Copy the three elements from the DropDownList and paste them between the opening and closing tags of the CheckBoxList. The code should be:

List Controls C# Visual Basic CSS C# Visual Basic CSS

List Controls Switch to Design View and then drag a Button to the right of the CheckBoxList (The button will be placed below the CheckBoxList). Drag a label control and drop it next to the button. Create some space between the button and label1 by positioning your cursor there and pressing Enter twice. Double-click the button to enter the code: Label1.Text = "In the DDL you selected " & DropDownList1.SelectedValue & " " For Each item As ListItem In CheckBoxList1.Items If item.Selected Then Label1.Text &= "In the CBL you selected " & item.Value & " " End If Next Save the changes and request the page in the browser Note: The &= assigns the Value of the list item together with the text “In the CBL you selected “ to the Text property of the Label1. It is shorthand for this: Label1.Text = Label1.Text + "In the CBL you selected " + item.Value + " "

Container Controls The ability to group related content and controls e.g. Panel PlaceHolder MultiView Wizard

Using the Panel Control Start by creating a new Web Form called Containers.aspx in the Demos folder Switch into Design View and drag a CheckBox and a Panel control inside the element Change the Text property of the CheckBox to Show Panel and set its AutoPostBack property to True Set the Visible property of the Panel to False. This hides the Panel control when the page first loads Inside the Panel type I am visible now. Double-click the CheckBox and add the following code: Panel1.Visible = CheckBox1.Checked

Using the Panel Control Save the changes and press Ctrl F5 Click the CheckBox to see the Panel appearing

The ASP.NET State Engine The HTTP protocol used to request and serve pages in a web browser is stateless. This means that the web server does not keep track of requests that have been made from a specific browser. The web server has no recollection of pages you requested previously; which leads to problems. E.g. for a login screen to fill in the username automatically and/or the “Remember me next time” to retain its selection.

How the State Engine Works The state engine in ASP.NET is capable of storing state for many controls. Under the Demos folder create a new page called State.aspx From Design View click inside the element and add a table with 2 rows and 2 columns by choosing Table  Insert Table from the main menu In first cell of the first row, drag a label. In the first cell of the second row drag a Calendar control. From the Smart Tasks panel click the Auto Format and select Simple and click OK. Drag a button into each of the 2 cells of the right column of the table

How the State Engine Works Click the first button and set its ID to btnSetDate and its Text to Set Date The other button call it btnPlainPostBack and set its text property to Plain PostBack

How the State Engine Works Double-click the Set Date button and add the code: Label1.Text = DateTime.Now.ToString() Open the page in the browser with Ctrl F5 Select a date. Notice as soon as you click the date, the page seems to reload, caused by a postback. Click the Set Date button few times. Then click the Plain PostBack button. Go back to VWD and change the EnableViewState property of the label to False. Ctrl F5 and repeat the previous steps to see what happens now

How the State Engine Works Check your HTML page source A form can be submitted in two ways: with POST or with GET. In the former case, all data from the form is added to the body of the request and then sent to the server. In case of the GET method, all the data is appended to the actual address of the request. Also look at the hidden ViewState field This is to protect the information stored and to decrease the size of it ASP.NET has converted the page state in the string you see.