1 / 93

Web/Database Connectivity with ASP.NET

Web/Database Connectivity with ASP.NET. David Henson. dhenson@certifiednetworks.com. Class Logistics. • Class Hours • Classroom Setup • Class Format. • https://www.certifiednetworks.com. Course Outline. Module 1 - Web Overview Module 2 - ASP.NET Overview Module 3 - ASP.NET Webform

lnorwood
Download Presentation

Web/Database Connectivity with ASP.NET

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Web/Database Connectivity with ASP.NET David Henson dhenson@certifiednetworks.com

  2. Class Logistics • Class Hours • Classroom Setup • Class Format • https://www.certifiednetworks.com

  3. Course Outline Module 1 - Web Overview Module 2 - ASP.NET Overview Module 3 - ASP.NET Webform Module 4 – Debugging/Tracing Module 5 - .NET Controls Module 6 – ADO.NET

  4. Course Outline, Contd. Module 7 – Advanced Data Topics Module 8 - Security Module 9 – ASP.NET Email/File Integration Module 10 - XML

  5. Module 1 – Web Services Overview

  6. Definitions • ASP • ASP.NET • HTTP • IIS • Virtual Directory • Browser

  7. Web Server/Client Interaction

  8. HTTP Protocol • Header • Body

  9. Lab 1A – Viewing HTTP Traffic • Things to look for: – Header – Body – Server Response Code

  10. Methods For Dynamic Server- Based Content • CGI – Opens separate executable • ASP – Interpreted each page load, Windows Only • JSP – Portable, fast familiar to Java Programmers • PHP – Cross Platform, C & Perl Like • ASP.NET – Compiled, integrated into framework

  11. HTML Protocol • End result of any dynamic server side product- dictates rendering of page • Tags: <html> <body> <table><tr><td> <form> <a href=“…”> <br> <input type=“…”>

  12. Lab 01B – Creating an E- Commerce Website Framework

  13. Module 2 – ASP.NET Overview

  14. .NET Framework Web Services User Interface ADO.NET: Data & XML Base Class Library Common Language Runtime

  15. What is ASP.NET • Not a programming language but a delivery mechanism • Can leverage any .NET programming language, like built-in VB.NET, C#, and third party like Delphi

  16. .NET Features • Multiple Language Support • Increased Performance – Compiled code – Cache • Server Controls • Web Services • Improved Security • Greater Scalability • Cookie-less Sessions • Easy Configuration and Deployment

  17. Classic ASP Programming Model • Procedural, Top to Bottom Approach • HTML/ASP Code Mixed

  18. Classic ASP Example

  19. Classic Windows Programming Model • Create a Form • Drop Controls On Form • Write Event Handlers • User activity generates messages which are handled by the event handlers

  20. Demonstration – Spy++ • What to look for: – Event Driven Model of Windows

  21. ASP.NET Programming Model • Process Same as Windows Programming • Connectivity/State is emulated

  22. ASP.NET Example

  23. ASP.NET Configuration Files • Web.con • <%@page ... %> tag

  24. Demonstration – Visual Studio .NET Quick Tour

  25. Module 3 – ASP.NET Webforms

  26. Webforms Defined • aspx extension • @Page Directive <%@ Page Language="vb" %> • Framework Is an Object Model • Denoted by the runat="server" Attribute <Form runat="server"> </Form> • Contain Client-side and Server-side Code • Contain HTML and Server Controls

  27. Events • User requests dbdemo.aspx • Page_Load event detected • Sub Page_Load() executed • All event handlers are called in a single flow of motion, before the user ever gets to see the page.

  28. WebForm Main Events • Events Occur Each Time the Page is Accessed • Page_Init • Page_Load • Controls(only when form is posted back…Button1_Click for example) • Page_Unload

  29. Other Supported Webform Events • Error – whenever the page generates one • CommitTransaction • AbortTransaction

  30. Defining Server Control Event Handlers <asp:button id=“Button1” onclick=“MyHandler”/>

  31. Webform Validation • Page.IsValid will be false if any control has failed validation • Asp:ValidationSummary Control • Set Display property of any validation control to None • ValidationSummary Control will display msg from all controls • Client Side Validation Setting: Set BaseValidator.EnableClientSideScript for any contol

  32. Manual Validation • Add form submit button with CausesValidation set to False, then call Page.Validate yourself. • Take action based upon page.IsValid property

  33. Lab 03A – Working with Web Forms

  34. Module 4 – Debugging/Tracing • Debugging • Tracing • Error/Exception Handling

  35. To Compile in Debug Mode • 1. Add a "Debug=true" directive at the top of the file that generated the error. Example: <%@ Page Language="C#" Debug="true" %> or: 2) Add the following section to the configuration file of your application: <configuration> <system.web> <compilation debug="true"/> </system.web> </configuration>

  36. Using the Debugger • Setting Breakpoints • Debug shortcut keys:

  37. Logging Exceptions Try …some code Catch err AS Exception Dim log as New EventLog() Log.Source = “MyPage” Log.WriteEntry(err.Message, EventLogEntryType.Error) End Try

  38. Viewing Eventlogs

  39. Display of Errors • Error Modes: – RemoteOnly – Default, hides details if not local client – Off – Shows all details and source…good for development, not production – On – Displays custom error page if any, or generic error message

  40. Custom Error Pages <configuration> <system.web> <customerErrors defaultRedirect=“MyError.aspx”> <error statusCode=“404” redirect=“My404.aspx”> </customErrors> </system.web> </configuration> Only works if ASP.NET is handling the request(.aspx extension)

  41. Lab 04A – Debugging/Tracing • Enabling Tracing • Exception Handling • Debugging • Writing to the Windows Eventlog • Custom Error Messages

  42. Module 5 – .NET Controls

  43. The ASP.NET Server Controls • HTML Server Controls • ASP.NET Web Form Controls • ASP.NET List Controls • ASP.NET Templated Controls • ASP.NET Rich Controls • ASP.NET Validation Controls • ASP.NET Mobile Controls

  44. User Controls

  45. Custom Server Controls

  46. Key Concept - Rendering • Controls are responsible for rendering themselves • You can override the Render() function on your own controls

  47. HTML Controls • Best for “Converting” from ASP to ASP.NET • Add the runat=“server” attribute to existing controls

  48. ASP.NET Controls • Mirror HTML Controls • More Consistent Properties/Naming Across Control Types

  49. Common ASP.NET Webform Control Properties • ID • Text

  50. Control Validation

More Related