Your SlideShare is downloading. ×
Mastering the .NET Code Model
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Mastering the .NET Code Model

1,406
views

Published on

Learn how the .NET page life cycle works, review best practices for creating n-tier applications and discover how to use Ajax to create interactive applications. …

Learn how the .NET page life cycle works, review best practices for creating n-tier applications and discover how to use Ajax to create interactive applications.

Published in: Technology

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,406
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
39
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • And another one for when a Record Control is displaying data.
  • And finally for a record control when saving data.
  • OK. So we talked about a whole lot of things. We talked about the philosophy behind Iron Speed Designer and how it operates at a different level of granularity. It allows you to operate at a page or panel level. Then we talked about how code is organized into Section 1 and Section 2, followed by the class and control hierarchy and finally we talked about the calling hierarchy. We hope this short introduction helped you understand what happens behind the scenes in an Iron Speed Designer generated application. With that, now we are ready for your questions. Please send them via Chat. Brooke will queue them up and we will try to get you an answer for each of them.
  • Transcript

    • 1. Mastering the .NET Code Model Visit us: www.ironspeed.com Download the Free Edition: www.ironspeed.com/download
    • 2. ASP.NET Code Model
        • Single-File Page Model
          • Layout and Code in one ASPX file
          • Used only for the simplest applications
    • 3. ASP.NET Code Model
        • Code-Behind Page Model
          • Most common in practice
          • Separate Layout and Code
          • Layout in ASPX
          • Code-behind in .VB or .CS
          • No performance difference
          • Allows re-use of common code
          • Designers can design layout, while developers can write code
          • Best practice for an N-tier application
    • 4. Code-Behind
        • Code-Behind is specified in the ASPX
    • 5. Code-Behind
        • Code-Behind is derived from the Page class (or another subclass of Page class)
    • 6. Best Practices - .NET Code Model
        • Use Code-Behind Page Model for extensibility
    • 7. Page Lifecycle
    • 8. Page Lifecycle
        • Sequence of steps a page goes through
          • Initialize
          • Load the user interface controls
          • Read data from the database
          • Display the page
          • And later…
          • Validate data
          • Save data into database
          • Redirect back to calling page
          • etc.
    • 9. Page Lifecycle
        • .NET handles
          • Loading of the page
          • Converting ASP controls to HTML controls
          • Rendering controls on the page
        • But at key points during the page lifecycle, .NET raises events for you to do your work
        • Your job: Handle various events to load data from database, initialize content in controls
    • 10. .NET’s Event-based Model
        • Program by responding to events
        • Write an event handler
        • Initial page display has three events
        • User actions on page (e.g., button click) has one additional event
    • 11.  
    • 12. After Displaying a Page
        • Server releases the page instance
        • Nothing about the page or the data on the page is kept on the server
        • Any state information must be maintained by you in “ViewState”
    • 13. What is a Postback?
        • User’s action causes a Postback
          • An event is raised
          • Page instance is re-created
          • UI Control data is repopulated from ViewState
          • Server-side event handler is called
        • Examples
          • Button click
          • Selected item in dropdown
          • Typed text in a textbox
        • Must register Event Handler to request a postback
    • 14. User Actions cause “Postback”
        • Four events raised during Postback
        • Registered Event Handler called between Load and PreRender
    • 15.  
    • 16. During Postback
        • Check IsPostback to determine whether in Postback state
        • Performance Tip: Only load data during initial display (Not IsPostback)
    • 17. State Management
        • ViewState is a standard feature of .NET
        • By default, state information maintained in HTML sent to browser
        • Encoded, but not encrypted
    • 18. State Management
        • ViewState can be optionally saved in Session, Cache, File or Database - but:
          • Additional work required
          • Session or Cache can get timed out
          • File or Database requires regular cleanup
        • Bloats the page content, but best to leave it as Page
    • 19. Best Practices – Page Lifecycle
        • Do most of the work by handling Load event
          • Init should be used only for initializing event handlers
          • PreRender should only be used to handle dependent controls
          • Security for a page should be checked in Load
        • Use IsPostback extensively to improve performance and minimize loading data from database
        • Use “Page” ViewState – even though it sends lots of data to the browser
    • 20. Ajax
    • 21. Using Ajax
        • ASP.NET Ajax creates fast and flicker-free updates
        • Extremely simple to implement –
          • Just surround ASP Controls with UpdatePanel
        • Only sends back content that has changed
        • Browser only paints changed content
        • Can have multiple and/or nested UpdatePanels
        • Code-behind does not change when using Ajax
    • 22. Using Ajax
        • Can show progress using UpdateProgress
        • Use animated GIF image
    • 23. Best Practices – Ajax
        • Best to use a single UpdatePanel
          • Using multiple UpdatePanels may require special handling when updating dependent information
    • 24. Master Pages
    • 25. Master Pages
        • Creates a consistent layout
        • Centralizes common functionality
        • Easier to maintain
        • Typical use:
          • Master Page contains:
            • Styles
            • Header, Menu and Footer
          • Individual page contains:
            • Content
    • 26. Master Pages
    • 27. Master Pages
        • .NET merges Master pages with Page Content
        • Master pages can inherit from other master pages
    • 28. Best Practices – Master Pages
        • Create multiple Master Pages for different needs
        • Nest Master Pages if needed
        • Include all CSS Styles, Javascript, etc. in Master Pages
        • Keep Page Content focused on actual data
    • 29. N-Tier Applications
    • 30. N-Tier Application
        • Divide application into N-Tiers
          • Layout in ASPX pages
          • UI Code in Code-Behind code files
          • Business Layer
          • Data Access Layer
          • Stored Procedures
    • 31. N-Tier Application
    • 32. Best Practices – N-Tier Application
        • Changes to layout should not impact Code-Behind
        • Changes to Database Schema should have minimal impact on UI Layer
        • Data Access Layer must use Strongly Typed objects
        • Paging must be done in the database, not in memory
          • ASP GridView, ListView etc. do paging in memory
        • Concurrency handling is important in highly asynchronous applications
    • 33. Iron Speed Designer
    • 34. Iron Speed Designer
        • Implements Best Practices for
          • .NET Code Model
          • Page Lifecycle
          • Ajax
          • Master Pages
          • N-Tier Applications
        • Lets you focus on what is most important
          • Your business logic
          • Use the .NET Code Model knowledge to extend
    • 35. Three Recent Game Changing Enhancements
      • Layout Customizations
        • Use Spreadsheet Grid
      • Toolbox – Drag and drop
        • Easily add pre-configured panels and controls
      • Code Customizations
        • Use Excel-like Formulas
    • 36. Page Layout Customization
        • Spreadsheet shows a ‘logical representation’ of page section
        • Drag and drop to arrange controls
        • Designer converts page layout to HTML (ASPX) (You don’t have to know any HTML or ASPX!)
        • Cell Editor allows fine-grained tuning and formatting
          • Add any HTML or ASPX
          • Change font, bold, italics, alignment, cell borders, cell width
    • 37. Using Toolbox Controls
        • Drag and drop controls onto your Web page
        • Toolbox controls are databound – there’s nothing to hook up!
          • Fields, labels and entire panels!
    • 38. Formula Language
      • Game Changing Enhancement to Version7.0
        • Excel-like
        • Most common tasks can be done – 75 to 80%
        • No need to know VB.NET or C#
        • Easy to extend – local and global extensions
    • 39. Key Questions
      • What is your time worth?
      • What is the ROI?
    • 40. Questions?

    ×