This lecture presents:
WebSite Design using Master Page and Themes and Skins.
Website Navigation
ADO.NET Fundamentals using Connected Model and Disconnected Models
4. Master Page (.master)
A templates that renders common
appearance to all pages attached to it
Rich design time support
To work with them, we will create two
types of pages
MasterPages: a page template, contains
controls and content placeholders
ContentPages: references a single master
page, to acquire layout, add page specific
content in the content placeholders
5. .aspx .master
In page All common HTML
directive, MasterPageFile tags, <html>,<head>,<bo
= “masterpage url” dy>
Contain Content Control All common controls
that is linked to a certain Contain
ContentPlaceHolder in ContentPlaceholder
the master page Control where the
New content can be page content will appear
added only in the content
control
Master Page (.master)
9. Themes and skins
What is the problem?
◦ To make control properties consistent, not just
style properties
◦ To style complex controls like Calendar and
Grids
Themes:
◦ Are control-based, not HTML-based
◦ Are applied on the server
◦ Don’t cascade as in CSS
◦ Set in web.config or in each individual page
Skins:
◦ Are text files with .skin extension
◦ Contains a list of control tags and set properties
that need to be standardized
15. Themes and Skins
Applying Themes dynamically:
◦ Page.Theme
◦ Page.StyleSheet
This must be done in the PreInit event.
Why????????????
How to make a user
change themes in his
page?
17. ADO.NET
Contains managed classes to connect to
data sources (Relational DB), execute
commands, manage disconnected data.
It includes:
◦ Connection: establish connection to a
DataSource.
◦ Command: execute SQL commands and stored
procedures.
◦ DataReader: fast read-only, forward-only
access.
◦ DataAdapter: fill DataSet from a DataSource, to
apply changes to a DataSource, according to the
18. Connection class (implement
IDBConnection)
A limited-server resource must be
opened as late as possible and
release it as quickly as possible.
Connection String Stored in
web.config
22. DataReader Class
To read the data returned by a
SELECT command one record at a
time, in a forward-only, read-only
stream.
Provides the quickest possible access
to data.
25. SQL Injection Attacks
The process of passing SQL code into
an application, in a way that was not
intended or anticipated by the
application developer.
Affects only applications that use SQL
string building techniques to create a
command with user-supplied values.
Solution use parameterized
command or a stored procedure
30. Disconnected Model
Using DataSets you can:
◦ Work on multiple tables and relations
◦ Get ChildRows using the relations
◦ Search Tables by criteria using Select
Method
More in Pro ASP.NET 4 pages 340 -
344
37. Report #3
How to dynamically set a MasterPage
and in which state of the Page life
cycle?
What is a TreeView Control?
38. Lab #3
Create masterpage.master for the
site, with the date user control.
Create three skins
Default(green), Pink and Blue
(StyleSheet, image and skin for image
button)
Add a sitemap to masterpage
Add Home.aspx and Login.aspx
Modify the three
pages(register, books, checkout) to be
able to use the master page
39. Lab #3
In register.aspx
◦ Get the country and city from the
database
Bonus:
◦ Create modifyCities.aspx, using
disconnected model insert, edit and
delete cities.
40. Lab Hints
Control ID problem with masterpage
and css???
◦ Try ClientIDMode=static for page
41. Bonus
Add a usercontrol to change
themes, with the radiobuttons. Add it
to the masterpage. How will it be
applied to all pages????
42. REFERENCES
[1] Beginning ASP.NET 4 In C# 2010, Matthew
Macdonald, Apress
[2] Web Application Architecture
Principles, Protocols And Practices, Leon Shklar
And Richard Rosen, Wiley
[3] Professional AS P.NE T 4 In C# And VB, Bill
Evjen, Scott Hanselman And Devin Rader, Wiley
[4] Pro ASP.NET In C# 2010, Fourth
Edition,matthew Macdonald, Adam Freeman, And
Mario Szpuszta, Apress
Notes de l'éditeur
One way is by creating a template page that inherits System.Web.UI.Page, and use it as a parent to all other pagesVS Design doen’t support that
When a page with masterpage is requested, the master page must be rendered and merged with the page contents to create a single final, page to be rendered to the response
Master Directive
MasterPage.masterDefault.aspxTry writing outside of content holder see errorSee designer
If a property is specified in a theme and in the individual control, the theme overrides all other
Theme a folder contains css and skins
Try creating theme folder and add stylesTry creating skins for a calendar controlNo skin designer support, copy and past controls from pages after setting itTry cascading effect (theme vs. styesheettheme)
Only controls with the skinID will apply the skin
After PreInitthrow an exception because after preinit controls are createdTheme changes aren’t read until page reload and passed PreInitstageuseServer.Transfer to refresh to itself.
Standardized ADO.NET through depending on a number of interfaces and base classes.
Connection.Close equivalent to connection.Dispose()