1 / 136

Advance Web Programming

ITEC5620 - Advance Web Programming. Advance Web Programming. อ.ชไลเวท พิพัฒพรรณวงศ์ Chalaivate Pipatpannawong Computer Instructor Microsoft Certificate Professional Web : www.9Expert.co.th ; Thaiwebdev.com E-Mail: chalaivate@chalaivate.com. ปริญญาโท สาขาวิชา เทคโนโลยีสารสนเทศ.

Download Presentation

Advance Web Programming

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. ITEC5620 - Advance Web Programming Advance Web Programming อ.ชไลเวท พิพัฒพรรณวงศ์ Chalaivate Pipatpannawong Computer Instructor Microsoft Certificate Professional Web : www.9Expert.co.th ; Thaiwebdev.com E-Mail: chalaivate@chalaivate.com ปริญญาโท สาขาวิชา เทคโนโลยีสารสนเทศ

  2. What's New with Visual Studio 2005 and ASP.NET 2.0

  3. New Features at a Glance Data Controls Login Controls Web Parts Other New Controls Controls Master Pages Themes and Skins Mobility and Localization Compilation Page Framework Membership Role Management Profiles Configuration Services and APIs Site Maps Health Monitoring Other Services

  4. What's New in Data Access • Data source controls • Declarative 2-way data binding • Data controls • GridView - Like the DataGrid, only better • DetailsView - Companion to GridView • SQL cache dependencies • Key cached items to database entities • Simplified data binding expressions

  5. ASP.NET 1.x Data Binding <asp:DataGrid ID="MyDataGrid" RunAt="server" /> ... <script language="C#" runat="server"> void Page_Load (Object sender, EventArgs e) { SqlConnection connection = new SqlConnection ("server=localhost;database=pubs;integrated security=true"); try { connection.Open (); SqlCommand command = new SqlCommand ("select title_id, titles, price from titles"); MyDataGrid.DataSource = command.ExecuteReader (); MyDataGrid.DataBind (); } finally { connection.Close (); } } </script>

  6. ASP.NET 2.0 Data Binding <asp:SqlDataSource ID="Titles" RunAt="server" ConnectionString="server=localhost; database=pubs;integrated security=true" SelectCommand="select title_id, title, price from titles"/> <asp:DataGrid DataSourceID="Titles" RunAt="server" />

  7. Declarative Data Binding Chalaivate Pipatpannawong Chalaivate.COM

  8. What's New for UIs • Master pages • "Visual inheritance" for Web pages • Applied declaratively or programmatically • Themes and skins • Theme controls, pages, and entire sites • Applied declaratively or programmatically • New controls (more than 50 in all) • Menus, TreeViews, Wizards, and more

  9. Theming a Page <%@ Page Theme="BasicBlue"> Before After

  10. Chalaivate Pipatpannawong Computer Instructor www.9Expert.co.th chalaivate@9expert.com

  11. What's New in Security • Membership service • Service for managing users and credentials • Provider-based for flexible data storage • Login controls • Controls for logging in, creating new users, recovering lost passwords, and more • Role Management service • Combine forms authentication and role-based authorization without writing code!

  12. Validating Logins if (Membership.ValidateUser (UserName.Text, Password.Text)) RedirectFromLoginPage (UserName.Text, RememberMe.Checked);

  13. The Login Control <html> <body> <form runat="server"> <asp:Login RunAt="server" /> </form> </body> </html>

  14. Membership and Logins Chalaivate Pipatpannawong Computer Instructor www.9Expert.co.th chalaivate@9expert.com

  15. Profiles • Store per-user data persistently • Strongly typed access (unlike session state) • On-demand lookup (unlike session state) • Long-lived (unlike session state) • Supports authenticated and anonymous users • Accessed through dynamically compiled HttpProfileBase derivatives (HttpProfile) • Provider-based for flexible data storage

  16. Defining a Profile <configuration> <system.web> <profile> <properties> <add name="ScreenName" /> <add name="Posts" type="System.Int32" defaultValue="0" /> <add name="LastPost" type="System.DateTime" /> </properties> </profile> </system.web> </configuration>

  17. Using a Profile // Increment the current user's post count Profile.Posts = Profile.Posts + 1; // Update the current user's last post date Profile.LastPost = DateTime.Now;

  18. Persisting Data with Profiles Chalaivate Pipatpannawong Computer Instructor www.9Expert.co.th chalaivate@9expert.com

  19. Site Navigation • Navigation UIs are tedious to implement • Especially if they rely on client-side script • New controls simplify site navigation • TreeView and Menu - Navigation UI • SiteMapDataSource - XML site maps • SiteMapPath - "Bread crumb" control • Public API provides foundation for controls • Provider-based for flexibility

  20. Data-Driven Site Navigation Chalaivate Pipatpannawong Computer Instructor www.9Expert.co.th chalaivate@9expert.com

  21. Providers • New model for storing and managing state • Makes storage adaptable to different media • Used by many key ASP.NET services • Membership service • Role Management service and more • Built-in providers make ASP.NET state storage very flexible • Custom providers make it infinitely flexible

  22. The Provider Model Controls Login LoginStatus LoginView Other Login Controls Membership API Membership MembershipUser Membership Providers AccessMembershipProvider SqlMembershipProvider Other Membership Providers Membership Data Access SQL Server Other Data Stores

  23. Configuration • Administrative tools • ASP.NET MMC snap-in • Web Site Administration Tool (Webadmin.axd) • Configuration API • Read/write access to configuration settings • Simplified custom configuration sections • Instrumentation • Perf counters, health monitoring, and more

  24. Web Site Administration Tool Chalaivate Pipatpannawong Chalaivate.COM

  25. Web Parts • Framework for building portal-style apps • Patterned after SharePoint Portal Server • System.Web.UI.WebControls.WebParts • Rich UIs with minimal code • Edit page layout using drag-and-drop • Edit appearance and behavior and more • Seamless personalization • Intercommunication ("connections")

  26. Web Parts Chalaivate Pipatpannawong Chalaivate.COM

  27. What's New in Mobility • Unified Control Architecture • Adapters enable pages and controls to render markup for different device types • WML adapters provided by third parties • Device filters <asp:Label Text="Hello, world" RunAt="server" Nokia:Text="Hello, Nokia" Up:Text="Hello, OpenWave" /> OpenWave browsers Nokia browsers

  28. What's New in Localization • Auto-culture handling • Declarative mapping of Accept-Language headers to relevant thread properties • Simplified resource handling • Declarative mapping of control properties to resources using <%$ … %> expressions • Strongly typed programmatic resource loading • <asp:localize runat="server"> and more

  29. What's New in Compilation • Autocompile anything • CS files, VB files, RESX files, and so on • Simply drop files into special directories • Extensible with custom build providers • New code-behind model (code-behind 2.0) • Fixes fragilities in version 1 • Relies on partial class support in compilers • Precompile and deploy without source

  30. Dynamic Compilation vroot CS VB Code Files auto-compiled on first access WSDL XSD Resources RESX RESOURCE

  31. Build Providers • Components that autocompile files • <buildProviders> config section maps file types and directories to build providers <compilation ... > <buildProviders> <add extension=".resx" appliesTo="Code,Resources" type="System.Web.Compilation.ResXBuildProvider"/> <add extension=".wsdl" appliesTo="Code" type="System.Web.Compilation.WsdlBuildProvider"/> <add extension=".xsd" appliesTo="Code" type="System.Web.Compilation.XsdBuildProvider"/> ... </buildProviders> </compilation>

  32. Code-Behind 2.0 Hello.aspx <%@ Page CompileWith="Hello.aspx.cs" ClassName="MyPage_aspx" %> <html> <body> <form runat="server"> <asp:TextBox ID="Input" RunAt="server" /> <asp:Button Text="Test" OnClick="OnTest" RunAt="server" /> <asp:Label ID="Output" RunAt="server" /> </form> </body> </html>

  33. Code-Behind 2.0, Cont. Hello.aspx.cs using System; partial class MyPage_aspx { void OnTest (Object sender, EventArgs e) { Output.Text = "Hello, " + Input.Text; } }

  34. Precompilation • Precompile.axd precompiles sites in place to avoid first-access delays

  35. Deploying without Source • Aspnet_compiler.exe precompiles sites and deploys without source code

  36. Dynamic Compilation Chalaivate Pipatpannawong Computer Instructor www.9Expert.co.th chalaivate@9expert.com

  37. $ Expressions • Declarative mechanism for loading resources, connection strings, and more ASPX <asp:SqlDataSource ID="Titles" RunAt="server" ConnectionString="<%$ ConnectionStrings:Pubs %>" SelectCommand="select title_id, title, price from titles" /> Web.config <configuration> <connectionStrings> <add name="Pubs" connectionString="server=localhost;database=pubs;..." /> </connectionStrings> </configuration>

  38. Expression Builders • Components that evaluate $ expressions • <expressionBuilders> config section maps prefixes to expression builders <compilation ... > <expressionBuilders> <add expressionPrefix="Resources" type="System.Web.Compilation.ResourceExpressionBuilder" /> <add expressionPrefix="ConnectionStrings" type="System.Web.Compilation.ConnectionStringsExpressionBuilder" /> <add expressionPrefix="AppSettings" type="System.Web.Compilation.AppSettingsExpressionBuilder" /> </expressionBuilders> </compilation>

  39. Custom Expression Builders Chalaivate Pipatpannawong Computer Instructor www.9Expert.co.th chalaivate@9expert.com

  40. Cross-Page Posting • Pages can now post back to other pages • Relevant properties: • control.PostBackUrl - Identifies postback target • Page.PreviousPage - Returns reference to page that originated a cross-page postback • PreviousPage.IsCrossPagePostBack - Reveals whether a cross-page postback occurred • @ PreviousPageType directive provides strongly typed access to previous page

  41. Posting Back to Another Page <html> <body> <form runat="server"> <asp:TextBox ID="Input" RunAt="server" /> <asp:Button Text="Test" PostBackUrl= "PageTwo.aspx" RunAt="server" /> </form> </body> </html>

  42. Referencing a Control on the Previous Page (Weak Typing) <html> <body> <asp:Label ID="Output" RunAt="server" /> </body> </html> <script language="C#" runat="server"> void Page_Load (Object sender, EventArgs e) { if (PreviousPage != null && PreviousPage.IsCrossPagePostBack) { TextBox input = (TextBox) PreviousPage.FindControl ("Input"); Output.Text = "Hello, " + input.Text; } } </script>

  43. Referencing a Control on the Previous Page (Strong Typing) <%@ PreviousPageType VirtualPath="~/PageOne.aspx" %> <html> <body> <asp:Label ID="Output" RunAt="server" /> </body> </html> <script language="C#" runat="server"> void Page_Load (Object sender, EventArgs e) { if (PreviousPage != null && PreviousPage.IsCrossPagePostBack) Output.Text = "Hello, " + PreviousPage.InputBox.Text; } </script> Public property wrapping TextBox

  44. Cross-Page Postbacks Chalaivate Pipatpannawong Chalaivate.COM

  45. Validation Groups • Validation controls can now be grouped using new ValidationGroup property • Implemented by validation controls • Also implemented by Button, LinkButton, and ImageButton controls • Allows page to post back when validators in target group are satisfied • Fixes deficiency in ASP.NET 1.x

  46. Validation Groups Chalaivate Pipatpannawong Computer Instructor www.9Expert.co.th chalaivate@9expert.com

  47. Client Callbacks • "Lightweight" postbacks • Client-side callback manager transmits asynchronous XML-HTTP requests to server • Server receives and processes the request, but does not rerender the page • Callback manager receives the response and notifies the client via registered callback • Requires Internet Explorer 5.0 or higher • Great way to improve UI responsiveness

  48. How Client Callbacks Work Client Server 1 2 Client Callback Manager Page Client initiates callback by calling function returned by GetCallback-EventReference Callback manager launches async XML-HTTP call to server 3 Page's RaiseCall-backEvent method is called 5 4 Client is notified that the call completed and handed the result Callback manager is notified that the call completed

  49. Client Callbacks Chalaivate Pipatpannawong Computer Instructor www.9Expert.co.th chalaivate@9expert.com

  50. Who's Got the Focus? • In ASP.NET 1.x, client-side script was needed to assign focus to a control • In ASP.NET 2.0, use Page.SetFocus <asp:TextBox ID="UserName" RunAt="server" /> . . . <script language="C#" runat="server"> void Page_Load (Object sender, EventArgs e) { SetFocus ("UserName"); } </script>

More Related