Framework Based Internet Applications Styles, Themes, and Master Pages

Slides:



Advertisements
Similar presentations
HTML Basics Customizing your site using the basics of HTML.
Advertisements

KompoZer. This is what KompoZer will look like with a blank document open. As you can see, there are a lot of icons for beginning users. But don't be.
HTML Overview - Cascading Style Sheets (CSS). Before We Begin Make a copy of one of your HTML file you have previously created Make a copy of one of your.
CHAPTER 7 STYLING CONTENT WITH CASCADING STYLE SHEETS.
Introduction to CSS.
Web Design with Cascading Style Sheet Lan Vu. Overview Introduction to CSS Designing CSS Using Visual Studio to create CSS Using template for web design.
User Controls, Master Pages, GridView. Content User Controls Styles, Themes, Master Pages Working with Data GridView Muzaffer DOĞAN - Anadolu University2.
Chapter 3 Working with Text and Cascading Style Sheets.
Asp.NET Page Composition. Slide 2 Lecture Overview Work with master pages and content pages.
Tutorial 3: Adding and Formatting Text. 2 Objectives Session 3.1 Type text into a page Copy text from a document and paste it into a page Check for spelling.
CSS (Cascading Style Sheets): How the web is styled Create Rules that specify how the content of an HTML Element should appear. CSS controls how your web.
 Missing (or duplicate) semicolons can make the browser completely ignore the style rule.  You may add extra spaces between the properties/values to.
Working with Text and Cascading Style Sheets Adobe Dreamweaver Chapter 3.
© 2010 Delmar, Cengage Learning Chapter 7 Using Styles and Style Sheets for Design.
Advanced CSS - Page Layout. Advanced CSS  Compound Selectors:  Is a Dreamweaver term, not a CSS term.  Describes more advanced types of selectors such.
Chapter 3 Working with Text and Cascading Style Sheets.
Ch6:creating consistent looking web sites. Master pages Master page defines a combination of fixed content and content place holder to hold the web page(.aspx)
E-Commerce: Introduction to Web Development 1 Dr. Lawrence West, Management Dept., University of Central Florida Topics What is a Web.
XP Dreamweaver 8.0 Tutorial 3 1 Adding Text and Formatting Text with CSS Styles.
Essentials of HTML Class 4 Instructor: Jeanne Hart
Copyright 2007, Information Builders. Slide 1 Understanding Basic HTML Amanda Regan Technical Director June, 2008.
© 2011 Delmar, Cengage Learning Chapter 8 Using Styles and Design Style Sheets for Design.
CS134 Web Design & Development Cascading Style Sheets (CSS) Mehmud Abliz.
Use CSS to Implement a Reusable Design Selecting a Dreamweaver CSS Starter Layout is the easiest way to create a page with a CSS layout You can access.
Things like Textboxes, Lables, ‘n’at. ASPX page is not HTML Controls are rendered into markup that a browser can understand Some controls are rendered.
© 2011 Delmar, Cengage Learning Chapter 3 Working with Text and Cascading Style Sheets.
CSE 409 – Advanced Internet Technology Today you will learn  Styles  Themes  Master Pages Themes and Master Pages.
LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE HTML and CSS 8th Edition Chapter 8: Working with Style Sheets.
Tutorial 3 Adding and Formatting Text with CSS Styles.
CHAPTER 4 CREATING STYLES AND LAYOUTS WITH CSS. CHAPTER OBJECTIVES Create ID-based styles Position content with CSS Format text with CSS Identify CSS.
Web Technologies Beginning Cascading Style Sheets (CSS) 1Copyright © Texas Education Agency, All rights reserved.
Positioning Objects with CSS and Tables
1111 Master Pages Beginning ASP.NET in C# and VB Chapter 6.
- WE’LL LOOK AT THE POSITION PROPERTY AND HOW CSS RESOLVES CONFLICTS BETWEEN STYLING INSTRUCTIONS The position property; CSS specificity hierarchy.
NASRULLAHIBA.  It is time to take your web designing skills to the next level with Cascading Style Sheets (CSS). They are a way to control the look and.
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.
STYLING WITH THEMES Active server pages (ASP.NET) 1 Chapter-5.
Chapter 4 Frames and Cascading Style Sheets. Frames Frames divide a browser window into two or more separate pieces or panes, with each pane containing.
1 Cascading Style Sheet (CSS). 2 Cascading Style Sheets (CSS)  a style defines the appearance of a document element. o E.g., font size, font color etc…
Introduction To CSS. Lesson 1: History of CSS CSS was proposed in 1994 as a web styling language. To helps solve some of the problems HTML 4. There were.
Creating Consistent Looking Websites
Framework Based Internet Applications
ASP.NET Forms.
Create and edit web pages 4
Working with ASP.NET Master Pages.
4.01 Cascading Style Sheets
Bare boned notes.
Chapter 8 User Controls.
Positioning Objects with CSS and Tables
Bare bones notes.
IS 360 Declaring CSS Styles
ASP.NET Web Controls.
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Website Design 3
Introduction to CSS.
Introducing ASP.net with Visual Studio Environment
Working with Text and Cascading Style Sheets
Using Cascading Style Sheets (CSS)
Some Stuff You Need to Know
Building ASP.NET Applications 2
Bare bones notes.
Web Development Using ASP .NET
Using Templates and Library Items
Web Design & Development
Cascading Style Sheets
4.01 Cascading Style Sheets
5.00 Apply procedures to organize content by using Dreamweaver. (22%)
Positioning Objects with CSS and Tables
Introduction to Styling
Presentation transcript:

Framework Based Internet Applications Styles, Themes, and Master Pages ITEC 420 Framework Based Internet Applications Styles, Themes, and Master Pages

Styles, Themes and Master Pages To integrate your web pages into a unified, consistent website, you need a few more tools. Three of the most important rules are: Sytles Themes And Master pages

Styles CSS gives you a wide range of consistent formatting properties that you can apply to any HTML element. CSS is a standard, which is supported via all modern browsers. Style Types can be applied via three ways Inline style: is that placed directly inside an HTML tag Ex: <p style=”background:Blue”>This text is blue </p> Internal style sheet: An internal style sheet is a collection of styles that are placed in the <head> section of your web page markup. You can then use the styles from this style sheet to format the web controls on that page. External style sheet: An external style sheet is similar to an internal style sheet, except it’s placed in a completely separate file. This is the most powerful approach, because it gives you a way to apply the same style rules to many pages.

Styles Creating a Basic Inline Style <p style="background: Blue">This text has a blue background.</p> Every style consists of a list of one or more formatting properties. In the preceding example, the style has a single formatting property, named background, which is set to the value Blue. To add multiple style properties, you simply separate them with semicolons, as shown here: <p style="color:White; background:Blue; font-size:x-large; padding:10px"> This text has a blue background.</p> You can use the same approach to apply formatting to a web control using a style. However, you don’t need to, because web controls provide formatting properties. For example, if you create a Label control like this: <asp:Label ID="MyLabel" runat="server" ForeColor="White" BackColor="Blue" Font-Size="X-Large">Formatted Text</asp:Label> it’s actually rendered into this HTML, which uses an inline style: <span id="MyLabel" style="color:White; background-color:Blue; font-size:X-Large"> Formatted Text</span> Incidentally, if you specify a theme and set formatting properties that overlap with your style, the properties have the final say.

Style Builder Visual Studio provides an indispensable stye builder that lets you create styles by picking and choosing your style preferences in a dedicated dialog box. As you will remember every object will be created inside a <div> and if you apply style settings to <div> all elements inside this div will be affected from this settings(Assuming controls are not overwriting to these). To examine drop some controls into an aspx file and choose Format--> New Style from the menu

Style Builder IN the selector box at the top of the window, choose Inline style to specify that you're creating your style directly in the HTML markup. Here you will find explanations related with style settings dialog box.

CSS Properties Window Once you have created a style, you have easy options for modifying it in Visual Studio. From menu View-->CSS properties When a control focused its css properties will be displayed. If you decide that you want to return to the style builder to change a style, the process is fairly straightforward. First, select the element that has the inline style. Next, look at the Applied Rules list at the top of the CSS Properties window, which should show the text < inline style >. Right-click that text and choose Modify Style to open the Modify Style dialog box, which looks identical to the New Style dialog box you considered earlier. You can not use the CSS Properties window to create a style. If you select an element that doesn't have a style applied, you won't see anything in the CSS Properties window

Creating a Style Sheet To create a style sheet in Visual Studio, choose website -> Add new item. Then pick the Style sheet template, specify a file name and click add. . nm { } is a CSS class p.nm { } is a CSS class which can be applied to p elements body { } rules will apply to all body elements. Once a css class created can be applied through the CssClass property of controls. The styles could be applied through the View->Apply Styles menu item.

Themes Aim: The problem is that CSS rules are limited to a fixed set of style attributes. They allow you to reuse specific formatting details (fonts, borders, foreground and background colors, and so on), but they obviously can’t control other aspects of ASP.NET controls. For example, the CheckBoxList control includes properties that control how it organizes items into rows and columns. Although these properties affect the visual appearance of the control, they’re outside the scope of CSS, so you need to set them by hand. Additionally, you might want to define part of the behavior of the control along with the formatting. For example, you might want to standardize the selection mode of a Calendar control or the wrapping in a TextBox. This obviously isn’t possible through CSS. The themes feature fills this gap. Like CSS, themes allow you to define a set of style details that you can apply to controls in multiple pages. However, with CSS, themes aren’t implemented by the browser. Instead, ASP.NET processes your themes when it creates the page. Themes don’t replace styles. Instead, they complement each other. Styles are particularly useful when you want to apply the same formatting to web controls and ordinary HTML elements. Themes are indispensable when you want to configure control properties that can’t be tailored with CSS.

How Themes Work They are application specific. To use a theme, a folder must be created that defines it. This folder must be placed ina folder named App_Themes. One application can contain more than one theme. Only one theme can be active at a time on a given page. To actually make your theme accomplish anything, you need to create at least one skin file in the theme folder. A skin file is a text file with the .skin extention. ASP.NET never serves skin files directly- instead, they're used behind the scenes to define a theme.

How Themes Works A skin file is essentially a list of control tags-with a twist. The control tags in a skin file don't need to completely define the control. Instead, they need to set only the properties that you want to standardize. For example, if you’re trying to apply a consistent color scheme, you might be interested in setting only properties such as ForeColor and BackColor. When you add a control tag for the ListBox in the skin file, it might look like this: <asp:ListBox runat="server" ForeColor="White" BackColor="Orange"/> The runat="server" portion is always required. Everything else is optional. You should avoid setting the ID attribute in your skin, because the page that contains the ListBox needs to define a unique name for the control in the actual web page. It’s up to you whether you create multiple skin files or place all your control tags in a single skin file. Both approaches are equivalent, because ASP.NET treats all the skin files in a theme directory as part of the same theme definition. Often, it makes sense to put the control tags for complex controls (such as the data controls) in separate skin files.

Add a Theme To add a theme to your project, select Website ä Add New Item, and choose Skin File. Visual Studio will warn you that skin files need to be placed in a subfolder of the App_Themes folder and ask you whether that’s what you intended. Unfortunately, Visual Studio doesn’t include any design-time support for creating themes,so it’s up to you to copy and paste control tags from other web pages. Here’s a sample skin that sets background and foreground colors for several common controls: <asp:ListBox runat="server" ForeColor="White" BackColor="Orange"/> <asp:TextBox runat="server" ForeColor="White" BackColor="Orange"/> <asp:Button runat="server" ForeColor="White" BackColor="Orange"/> To apply the theme in a web page, you need to set the Theme attribute of the Page directive to the folder name for your theme. (ASP.NET will automatically scan all the skin files in that theme.) <%@ Page Language="C#" AutoEventWireup="true" ... Theme="FunkyTheme" %> You can make this change by hand, or you can select the DOCUMENT object in the Properties window at design time and set the Theme property (which provides a handy drop-down list of all your web application’s themes). Visual Studio will modify the Page directive accordingly.

Add a Theme When you apply a theme to a page, ASP.NET considers each control on your web page and checks your skin files to see whether they define any properties for that control. If ASP.NET finds a matching tag in the skin file, the information from the skin file overrides the current properties of the control.

Handling Theme Conflicts As you’ve seen, when properties conflict between your controls and your theme, the theme wins. However, in some cases you might want to change this behavior so that your controls can fine-tune a theme by specifically overriding certain details. ASP.NET gives you this option, but it’s an all-or-nothing setting that applies to all the controls on the entire page. To make this change, just use the StyleSheetTheme attribute instead of the Theme attribute in the Page directive. (The StyleSheet designation indicates that this setting works more like CSS.) Here’s an example: <%@ Page Language="C#" AutoEventWireup="true" ... StyleSheetTheme="FunkyTheme" %> Another option is to configure specific controls so they opt out of the theming process entirely. To do this, simply set the EnableTheming property of the control on the web page to false. ASP.NET will still apply the theme to other controls on the page, but it will skip over the control you’ve configured. <asp:Button ID="Button1" runat="server" ... EnableTheming="false" />

Applying a Theme To an Entire Website Using the Page directive, you can bind a theme to a single page. However, you might decide that your theme is ready to be rolled out for the entire web application. The cleanest way to apply this theme is by configuring the <pages> element in the web.config file for your application, as shown here: <configuration> <system.web> <pages theme="FunkyTheme"> ... </pages> </system.web> </configuration>

Applying a Theme To an Entire Website If you want to use the style sheet behavior so that the theme doesn’t overwrite conflicting control properties, use the StyleSheetTheme attribute instead of Theme: <configuration> <system.web> <pages styleSheetTheme="FunkyTheme"> ... </pages> </system.web> </configuration> Either way, when you specify a theme in the web.config file, the theme will be applied throughout all the pages in your website, provided these pages don’t have their own theme settings. If a page specifies the Theme attribute, the page setting will take precedence over the web.config setting. If your page specifies the Theme or StyleSheetTheme attribute with a blank string (Theme=""), no theme will be applied at all. Using this technique, it’s just as easy to apply a theme to part of a web application. For example, you can create a separate web.config file for each subfolder and use the <pages> setting to configure different themes.

Creating Multiple Skins for the Same Control In the same skin ASP.NET allows you to create multiple declarations for the same control. Ordinarily, if you create more than one theme for the same control, ASP.NET will give you a build error stating that you can have only a single default skin for each control. To get around this problem, you need to create a named skin by supplying a SkinID attribute. Here’s an example: <asp:ListBox runat="server" ForeColor="White" BackColor="Orange" /> <asp:TextBox runat="server" ForeColor="White" BackColor="Orange" /> <asp:Button runat="server" ForeColor="White" BackColor="Orange" /> <asp:TextBox runat="server" ForeColor="White" BackColor="DarkOrange" Font-Bold="True" SkinID="Dramatic"/> <asp:Button runat="server" ForeColor="White" BackColor="DarkOrange" The catch is that named skins aren’t applied automatically like default skins. To use a named skin, you need to set the SkinID of the control on your web page to match. You can choose this value from a drop-down list that Visual Studio creates based on all your defined skin names, or you can type it in by hand: <asp:Button ID="Button1" runat="server" ... SkinID="Dramatic" /> If you don’t like the opt-in model for themes, you can make all your skins named. That way, they’ll never be applied unless you set the control’s SkinID.

Master Page Basics How to deal with the complexity of different pages that need to look and act the same. One option is to subdivide the page into frames. Frames are an HTML feature that lets the browser show more than one web page alongside another. Unfortunately, frames have problems of their own, including that each frame is treated as a separate document and requested separately by the browser. This makes it difficult to create code that communicates between frames. A better choice is to use ASP.NET’s master pages feature, which allows you to define page templates and reuse them across your website.

Master Page Basics Master pages are similar to ordinary ASP.NET pages. Like ordinary pages, master pages are text files that can contain HTML, web controls, and code. However, master pages have a different file extension (.master instead of .aspx), and they can’t be viewed directly by a browser. Instead, master pages must be used by other pages, which are known as content pages. Essentially, the master page defines the page structure and the common ingredients. The content pages adopt this structure and just fill it with the appropriate content.

A Simple Master Page and Content Page Website -> Add New item -> select Master page Drop some image to the contentplaceholder found in header block. Add a web form using Website -> Add new İtem -> select Web form and then check select a master page. Than choose the master page you create. Only contentplaceholder1 is editable in this form.

How Master Pages and Content Pages are Connected When you create a master page, you’re building something that looks much like an ordinary ASP.NET web form. The key difference is that although web forms start with the Page directive, a master page starts with a Master directive that specifies the same information. Here’s the Master directive for the simple master page shown in the previous example: <%@ Master Language="C#" AutoEventWireup="true" CodeFile="SiteTemplate.master.cs" Inherits="SiteTemplate" %>

How Master Pages and Content Pages … The ContentPlaceHolder is less interesting. You declare it like any ordinary control. Here’s the complete code for the simple master page: <%@ Master Language="C#" AutoEventWireup="true" CodeFile="SiteTemplate.master.cs" Inherits="SiteTemplate" %> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <img src="apress.jpg" /><br /> <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server"> </asp:ContentPlaceHolder> <i>This is a simple footer.</i> </form> </body> </html>

How Master Pages and Content Pages are….. When you create a content page, ASP.NET links your page to the master page by adding an attribute to the Page directive. This attribute, named MasterPageFile, indicates the associated master page. Here’s what it looks like: <%@ Page Language="C#" MasterPageFile="~/SiteTemplate.master" AutoEventWireup="true" CodeFile="SimpleContentPage.aspx.cs" Inherits="SimpleContentPage" Title="Untitled Page" %> Notice that the MasterPageFile attribute begins with the path ~/ to specify the root website folder. If you specify just the file name, ASP.NET checks a predetermined subfolder (named MasterPages) for your master page. If you haven’t created this folder, or your master page isn’t there, ASP.NET checks the root of your web folder next. Using the ~/ syntax is better, because it indicates unambiguously where ASP.NET can find your master page. As a result your page content becomes simpler due to the fact that head title tags of the pages comes from master page.

Default Content in Master Pages You might have some content that the content page may or may not want to replace. You can deal with this using default content. Here’s how it works: You create a master page and create a ContentPlaceHolder for the content that might change. Inside that tag, you place the appropriate HTML or web controls. (You can do this by hand using the .aspx markup or just by dragging and dropping controls into the ContentPlaceHolder.) So, what happens when you create a content page based on this master page? If you use Visual Studio, you won’t see any change. That’s because Visual Studio automatically creates a <Content> tag for each ContentPlaceHolder. When a content page includes a <Content> tag, it automatically overrides the default content. However, something interesting happens if you delete the <Content> tag from the content page. Now when you run the page, you’ll see the default content. In other words, default content appears only when the content page chooses not to specify any content for that placeholder. You might wonder whether the content pages can use some of the default content or just edit it slightly. This isn’t possible because the default content is stored only in the master page, not in the content page. As a result, you need to decide between using the default content as is or replacing it completely.