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
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()
ASP.NET Lecture 3
ASP.NET 4.0Julie IskanderMSC. Communication and Electronics
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
.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)
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
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
Connection class (implementIDBConnection) A limited-server resource must be opened as late as possible and release it as quickly as possible. Connection String Stored in web.config
Connection class (implementsIDBConnection) To retrieve connection string Using System.Web.Configuration
Command Class (ImplementsIDbCommand) Command class to execute any type of SQL statement.
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
Parameterized Commands A command that uses placeholders in the SQL text.
Disconnected Model Using DataAdapters and DataSets
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
Report #3 How to dynamically set a MasterPage and in which state of the Page life cycle? What is a TreeView Control?
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
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.
Lab Hints Control ID problem with masterpage and css??? ◦ Try ClientIDMode=static for page
Bonus Add a usercontrol to change themes, with the radiobuttons. Add it to the masterpage. How will it be applied to all pages????
REFERENCES  Beginning ASP.NET 4 In C# 2010, Matthew Macdonald, Apress  Web Application Architecture Principles, Protocols And Practices, Leon Shklar And Richard Rosen, Wiley  Professional AS P.NE T 4 In C# And VB, Bill Evjen, Scott Hanselman And Devin Rader, Wiley  Pro ASP.NET In C# 2010, Fourth Edition,matthew Macdonald, Adam Freeman, And Mario Szpuszta, Apress