ASP.NET Lecture 3


Published on

This lecture presents:
WebSite Design using Master Page and Themes and Skins.
Website Navigation
ADO.NET Fundamentals using Connected Model and Disconnected Models

Published in: Technology
1 Comment
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • 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 PreInitthrow an exception because after preinit controls are createdTheme changes aren’t read until page reload and passed PreInitstageuseServer.Transfer to refresh to itself.
  • Standardized ADO.NET through depending on a number of interfaces and base classes.
  • Connection.Close equivalent to connection.Dispose()
  • ADO.Net page
  • ADO.Net page
  • ASP.NET Lecture 3

    1. 1. ASP.NET 4.0Julie IskanderMSC. Communication and Electronics
    2. 2. Lecture Outlines WebSite Design ◦ Master Page ◦ Themes and Skins ◦ Website Navigation ADO.NET Fundamentals ◦ Connected Model ◦ Disconnected Models
    3. 3. Website Design“A Consistent Look andFeel”
    4. 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. 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)
    6. 6. Content Page
    7. 7. Convert from an HTML to an aspx page
    8. 8. 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
    9. 9. Themes and Skins
    10. 10. Convert from an HTML to an aspx page
    11. 11. Themes in Page Directive
    12. 12. Themes in web.config
    13. 13. Named Skins and SkinID What happens if all skins have IDs?
    14. 14. 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?
    15. 15. ADO.NETFundamentals
    16. 16. 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
    17. 17. 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
    18. 18. Connection class (implementsIDBConnection) To retrieve connection string Using System.Web.Configuration
    19. 19. Command Class (ImplementsIDbCommand) Command class  to execute any type of SQL statement.
    20. 20. Command Methods
    21. 21. 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.
    22. 22. SQL Injection
    23. 23. 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
    24. 24. Parameterized Commands A command that uses placeholders in the SQL text.
    25. 25. Convert from an HTML to an aspx page
    26. 26. Disconnected Model Using DataAdapters and DataSets
    27. 27. 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
    28. 28. Convert from an HTML to an aspx page
    29. 29. Navigation Controls(Self study in lab)
    30. 30. Site Map Add a web.sitemap ◦ XML file describing the site
    31. 31. Control Binding to a sitemap Controls to map to: ◦ SiteMap Path ◦ Menu
    32. 32. Reading Assignment #3 Applying Themes Dynamically
    33. 33. Report #3 How to dynamically set a MasterPage and in which state of the Page life cycle? What is a TreeView Control?
    34. 34. 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
    35. 35. 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.
    36. 36. Lab Hints Control ID problem with masterpage and css??? ◦ Try ClientIDMode=static for page
    37. 37. Bonus Add a usercontrol to change themes, with the radiobuttons. Add it to the masterpage. How will it be applied to all pages????
    38. 38. 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