web development using asp .net

50
Web Development Using Web Development Using ASP .NET ASP .NET CA – 240 CA – 240 Kashif Jalal Kashif Jalal Welcome to week – 2-1 Welcome to week – 2-1 of… of…

Upload: enrique-rios

Post on 30-Dec-2015

37 views

Category:

Documents


5 download

DESCRIPTION

Welcome to week – 2-1 of…. Web Development Using ASP .NET. CA – 240 Kashif Jalal. Chapter Objectives. Visual Studio .NET User Interface. Integrated Development Environment (IDE) – shared development environment Document windows (Edit & view documents) - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Web Development Using  ASP .NET

Web Development Using Web Development Using ASP .NETASP .NET

CA – 240CA – 240Kashif JalalKashif Jalal

Welcome to week – 2-1 Welcome to week – 2-1 of…of…

Page 2: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 2

Chapter ObjectivesChapter Objectives

Page 3: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 3

Visual Studio .NET User InterfaceVisual Studio .NET User Interface

• Integrated Development Environment (IDE) – shared development environment

• Document windows (Edit & view documents)

• Resource Tools (Windows, Toolbox, Toolbars)

– Main Window – create and view project files

– Solution Explorer – manage project files and resources

– Server Explorer window – access server public components, manage connections to databases

Page 4: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 4

Visual Studio .NET IDE LayoutVisual Studio .NET IDE Layout

Page 5: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 5

The The Solution Solution Explorer Explorer WindowWindow

Page 6: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 6

ASP .NET Project FilesASP .NET Project Files• AssemblyInfo.vb: An assembly is the building block of

anASP.NET application. The AssemblyInfo.vb file contains information about the assembly, it's version number, dependencies, etc.

• Global.asax: The Global.asax file, also known as the ASP.NET application file, is an optional file that contains code for responding to application-level events raised by ASP.NET or by HTTP modules. The Global.asax file resides in the root directory of an ASP.NET based application.

• Style.css: The Style.css file is a cascading style sheet file that holds styles for the page.

• Web.Config: The Web.Config file is an XML based file that contains configuration information for ASP.NET resources. This file contains information about how the server will handle your application. You can set options for security, permissions, tracing, etc in this file.

• WebForm1.aspx, WebForm1.aspx.vb: The WebForm1.aspx file is the file with which you work. You design the interface for your application, write client-side scripts in this file. The WebForm1.aspx.vb file the code behind where you write all the logic for the application that is processed back on the server.

Page 7: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 7

Visual Studio .NET User Interface Visual Studio .NET User Interface (continued)(continued)

• Resource Tools (continued)

– Properties window – set properties for objects, controls, and classes

– Document Tab – allows you to easily switch between open documents

– Toolbox – contains commonly used controls

– Task window – contains a to do list

Page 8: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 8

Creating a Web ApplicationCreating a Web Application

• A solution may contain pointers to many projects– Solution files are stored in a folder in the Visual

Studio Projects folder

• Project name is the folder name– By default, project name is the solution name– Project files are stored in the same folder or with

the Web site

• Web Server name– localhost, the machine name, IP address or

127.0.0.1 – Default Web site is http://localhost/[ProjectName]/

such as http://localhost/Chapter2/

Page 9: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 9

Creating a Web Application Creating a Web Application (continued)(continued)

• Create the Chapter2 project (Page 47)

– Make sure to verify that Visual Basic Projects is selected in Project Types pane

– Select the ASP.NET Web Application template

– Name the solution & project Chapter2, so the location is http://localhost/Chapter2

– View the default files, the hidden files within the Solution Explorer window

Page 10: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 10

The Start PageThe Start Page

• Provides access to recently created applications and help resources

– Some resources require access to the Internet

• You can reopen solutions by clicking on the hyperlink on the Projects tab

• Extensive documentation is provided on MSDN to customize the Start Page

Page 11: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 11

Navigating the WindowsNavigating the Windows

• Window layout can be customized

– Dockable – windows can be placed on top of each other

– Hide – closes the window

– Floating – drag and drop the window

– Auto Hide – stores the window as a tab; the window comes out like a drawer when you click on the tab

Page 12: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 12

The Solution Explorer WindowThe Solution Explorer Window

• Contains folders, project files, and hidden files

• Contains Reference folder – references for base class libraries and namespaces

• Contains a bin directory – stores the compiled application

– Compiled application is named after the project name with the file extension .dll

– ProjectName.dll

Page 13: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 13

The Solution Explorer Window The Solution Explorer Window (continued)(continued)

• Working with the Solution Explorer (Page 49)

– Create the images folder

– Import the images from Chapter02Data folder

– Add New Item – Web Form named home.aspx

– Save the project

Page 14: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 14

The Solution Explorer Window The Solution Explorer Window (continued)(continued)

Page 15: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 15

The ToolboxThe Toolbox

• Commonly used controls

• Organizes as tabs

– HTML tab – HTML controls

– Web Forms tab – ASP.NET Server controls

• Can be hidden and can slide out like the other windows

Page 16: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 16

Properties WindowProperties Window

• Set the properties for objects, controls, and classes

• Can set properties at design time or in the program code behind the page

Page 17: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 17

Properties Properties Window Window

(continued)(continued)

Page 18: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 18

HTML ControlsHTML Controls

• HTML is a markup language

<hr noshade>

• HTML standards set by World Wide Web Consortium (W3C)

• XHTML is current version (XML compliant)– Requires beginning and closing tags– If no closing tag, use < tag name />

<hr noshade />

Page 19: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 19

HTML Controls (continued)HTML Controls (continued)

• HTML Designer

– Design view – a graphical user interface

– HTML view – HTML code editor

• MS_POSITIONING property of BODY tag

– GridLayout – absolute position objects on the page

– FlowLayout – position elements in top-down format

• The targetSchema property – browser version

• IntelliSense – tries to predict what you will type

Page 20: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 20

Creating an HTML PageCreating an HTML Page

• Create the feedback.htm page (Page 53)

– Add the new page

– Set the page properties

– Insert an image

– Insert tags in code view, in Design view

– Modify the position of elements

– Insert tags in Design view using the Toolbox

• Save and build the solution

Page 21: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 21

Creating an HTML Page (continued)Creating an HTML Page (continued)

Page 22: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 22

IntelliSenseIntelliSense

Page 23: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 23

Previewing Your HTML PagePreviewing Your HTML Page

• Preview the page in the external and internal browser

• Note: If you preview the page by starting the application, the default page will appear in the browser. You can change the start page.

Page 24: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 24

Previewing Your HTML Page Previewing Your HTML Page (continued)(continued)

Page 25: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 25

User ControlsUser Controls

• Separate content and programming code that can be reused

• Easier to maintain• Examples: – heading, footers, menus– lists of records returned from a database– commonly used forms

• The User Control– compiled file ends in .ascx– first line identifies the file using the keyword Control– cannot have <html><head><body><form> tags

Page 26: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 26

User Controls (continued)User Controls (continued)

• Create the control (Ch2_Months.ascx)

<%@ Control %><select id=months><option>January</option><option>February</option><option>March</option><option>April</option><option>May</option><option>June</option><option>July</option><option>August</option><option>September</option><option>October</option><option>November</option><option>December</option></select>

Page 27: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 27

User Controls (continued)User Controls (continued)

• Registered with the Web page with @Register directive– TagPrefix is used to identify the User

Control’s namespace– TagName is the name of the control

<TagPrefix:TagName id = "TagID" runat = "server"/>

Page 28: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 28

User Controls (continued)User Controls (continued)

• Register the control in the Web page

<%@ Register TagPrefix="Months" TagName="ListMonths" src="Ch2_Months.ascx" %>

• Insert the control anywhere in the page– can reuse any user control many times – must provide a unique ID

<Months:ListMonths id = "ListMonths1" runat = "server"/>

Page 29: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 29

Creating and Registering a User Creating and Registering a User ControlControl

• Create and Register a User Control (Page 60)

– Create header.ascx

– Insert an image

– Add code to display a message and the date

– date is an object

– format date with ToShortDateString

• Modify the home.aspx page in HTML code view

– Register the User Control

– Insert the User Control

– Save, build, an preview the page

Page 30: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 30

Creating and Registering a User Creating and Registering a User Control (continued)Control (continued)

Page 31: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 31

Creating Cascading Style SheetsCreating Cascading Style Sheets

• Store information on how to present the site

• Separates content from presentation

• W3C sets standards for CSS

• Style Builder is graphical user interface to CSS

Page 32: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 32

CSS OverviewCSS Overview

• A style rule is the information that is applied to a single HTML tag, or a group of tags

• Name and value of the style is stored

• Syntax for the rules vary

– Inline rules apply to a single tag

– Embedded rules apply to all elements within a single Web page

– External rules apply to all elements within multiple Web pages

Page 33: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 33

Inline Style SheetsInline Style Sheets

• Placed inside the tag– Use the keyword style– Separate name and value pair with

semicolon

<tagname

style= "property1:value1;property2:value2">

Content goes here

</tagname>

<H1 style= "color:green;">Welcome to Tara Store!</H1>

Page 34: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 34

Embedded Style SheetsEmbedded Style Sheets

• Placed in the heading section

– Use the <style></style> tags– Separate name and value with = – Separate pairs with ;

<HTML><HEAD><TITLE>Sample Embedded Style Sheet</TITLE><STYLE>H1{ color=green; font-size=12;}</STYLE></HEAD><BODY><H1>Welcome to Tara Store!</H1></BODY></HTML>

Page 35: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 35

External Style SheetsExternal Style Sheets

• <LINK> tag attaches the style sheet to the page

– Rel – the file is a CSS– TYPE – the file is a text/css MIME type– No need for <style> tag, same format as

embedded– HREF – the location of the file (relative or

absolute URL)– Placed in the heading section

<Link rel=stylesheet type="text/css" href="URL ">

Page 36: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 36

Comments Within Cascading Style Comments Within Cascading Style SheetsSheets

• /* */ can be added to embedded or external style sheets

/* Styles.CSSCreated By: Katie KalataDate Created: 9/5/2005This style sheet is used to format the main menu*//* Corporate logo */H1 {color:green}/* Red heading */H2 {color:red}/* Blue heading */H3 {color:blue}

Page 37: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 37

Cascading Style Sheet RulesCascading Style Sheet Rules

• Cascading style sheets can contain conflicting styles rules.

• This rule puts the “cascading” in cascading style sheets, in general:

– Inline takes precedence over Embedded

– Embedded takes precedence over External

Page 38: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 38

ClassesClasses

• Class can be used to format a group of different tags or a subgroup of a specific tag

• Prefix the name of the class with a period

<HTML><HEAD><TITLE>Sample Embedded Style Sheet</TITLE>

<STYLE> H1 {color:green} .SelCat {color:red} .BlueHead {color:blue}</STYLE></HEAD>

Page 39: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 39

Classes (continued)Classes (continued)

• Apply the class with the keyword class

<BODY><h1>Welcome to Tara Store!</h1><h2 class="BlueHead">Product Listing:</h2>

<ul><li>Gifts</li><li class="SelCat">Jewelry</li><li>China & Crystal</li><li>Food</li><li>Clothing</li><li>Books, Music, & Videos</li>

</ul>

Page 40: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 40

Classes (continued)Classes (continued)

• Both headings would appear in blue

<h3 class="BlueHead">About Tara Store</h3><ul>

<li>What’s New</li><li>Current Sales</li><li>Location</li><li>Contact Us</li><li>Members Only</li>

</ul></BODY></HTML>

Page 41: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 41

CSS EditorCSS Editor

• CSS editor called the Style Builder • includes the IntelliSense feature • Color Picker– Web Colors tab - 216 colors supported by the majority of

computers and browsers– Named Colors tab - the 16 Windows colors and the 122

other named colors– System Colors tab - select a color that matches the colors

used to create system graphical user interfaces such as windows, menus, scrollbars, and buttons

– Custom Color tab - three slider controls to select the red, green, and blue (RGB) values

Page 42: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 42

Creating a Cascading Style SheetCreating a Cascading Style Sheet

• Modify the styles.css sheet (Page 68)

– Modify the style properties and values

– Edit the style sheet manually, use IntelliSense and use the Style Builder

– Add style rules

– Save the file

– Link the file to the feedback.htm page

– Preview the page in the browser

Page 43: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 43

Creating a Cascading Style Sheet Creating a Cascading Style Sheet (continued)(continued)

Page 44: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 44

Creating a Cascading Style Sheet Creating a Cascading Style Sheet (continued)(continued)

Page 45: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 45

Creating a Cascading Style Sheet Creating a Cascading Style Sheet (continued)(continued)

Page 46: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 46

Customizing the ToolboxCustomizing the Toolbox

• Customize the Toolbox (Page 74)

– Create a new tab

– Add a markup code fragment to tab and rename the control

• Toolbox – add additional tabs to organize controls

• Clipboard Ring - stores the list of items copied to the Clipboard

• Clipboard – area in memory that Windows uses to copy information

Page 47: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 47

Using Visual Studio .NET Help Using Visual Studio .NET Help ResourcesResources

• You can view the actual URL of the help files in the URL drop-down list box on the Web toolbar

• Results in a ranked list• Double-click on the items in the list to view the

documentation from within the user interface– Dynamic - help for the currently selected item

– Search - a textbox to enter a search phrase

– Index - a dictionary index that you can search for a term alphabetically

– Contents - navigate the help documentation using a table of contents

Page 48: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 48

Using Visual Studio .NET Help Using Visual Studio .NET Help Resources (continued)Resources (continued)

Page 49: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 49

SummarySummary

• Visual Studio .NET IDE layout can be customized

• Solution Explorer manages files and folders in one location

• Properties window sets properties for objects

• Toolbox organizes commonly used controls and can be customized

• HTML editor is used to create HTML pages in Design View or Code View

Page 50: Web Development Using  ASP .NET

Introduction to ASP.NET, Second Edition 50

Summary (continued)Summary (continued)

• User Controls – Contain controls and programming code; must be registered in the ASP.NET page before they are used

• Inline style sheets apply style rules to a single tag; embedded to a Web page; external to more than one page

• Help is provided within Visual Studio .NET through Dynamic, Index, Search, and Contents windows