Module 1: Creating Responsive Pages with Ajax Creating Partial-Page Updates by Using AJAX Scripting...

13
Module 1: Creating Responsive Pages with Ajax Creating Partial-Page Updates by Using AJAX Scripting Actions on the Web Client

Transcript of Module 1: Creating Responsive Pages with Ajax Creating Partial-Page Updates by Using AJAX Scripting...

Page 1: Module 1: Creating Responsive Pages with Ajax Creating Partial-Page Updates by Using AJAX Scripting Actions on the Web Client.

Module 1: Creating Responsive Pages with Ajax

•Creating Partial-Page Updates by Using AJAX

•Scripting Actions on the Web Client

Page 2: Module 1: Creating Responsive Pages with Ajax Creating Partial-Page Updates by Using AJAX Scripting Actions on the Web Client.

Lesson: Creating Partial-Page Updates by Using AJAX

•What are Partial-Page Updates?

•Discussion: Applications for Partial-Page Updates

•The ASP.NET AJAX Controls

•Implementing Partial-Page Updates

•Demonstration: Partial-Page Updates

•The ASP.NET AJAX Control Toolkit

Page 3: Module 1: Creating Responsive Pages with Ajax Creating Partial-Page Updates by Using AJAX Scripting Actions on the Web Client.

What are Partial-Page Updates?

• Initial download is the whole page

• Parts of the page can refresh while the rest of the page remains static

Page 4: Module 1: Creating Responsive Pages with Ajax Creating Partial-Page Updates by Using AJAX Scripting Actions on the Web Client.

Discussion: Applications for Partial-Page Updates

•Scenario: A small page that displays brief details about a single product.

•Scenario: A page that displays brief details about many products.

•Scenario: A page that displays brief details about share prices.

Page 5: Module 1: Creating Responsive Pages with Ajax Creating Partial-Page Updates by Using AJAX Scripting Actions on the Web Client.

The ASP.NET AJAX Controls

ScriptManagerManages script libraries and script files, partial-page rendering, and other functions.

UpdatePanelEnables sections of a page to be partially rendered without a page postback.

UpdateProgressProvides visual feedback on the browser when the contents on UpdatePanel controls refresh.

Timer Performs partial-page updates at defined intervals.

Page 6: Module 1: Creating Responsive Pages with Ajax Creating Partial-Page Updates by Using AJAX Scripting Actions on the Web Client.

Creating the ScriptManager Control:

Implementing Partial-Page Updates

<asp:ScriptManager ID="ScriptManager1" runat="server" />

<asp:ScriptManager ID="ScriptManager1" runat="server" />

Creating an Update Panel and Adding Controls:

<asp:UpdatePanel ID="UpdatePanel1” runat="server"> <asp:GridView ID=“GridView1” datasourceid=“MyDataSource”

autogeneratecolumns=“true” allowpaging=“false” runat=“server”> </asp:GridView> <asp:Button ID=“UpdateButton”

Text=“Refresh the Grid” runat=“server” /></asp:UpdatePanel>

<asp:UpdatePanel ID="UpdatePanel1” runat="server"> <asp:GridView ID=“GridView1” datasourceid=“MyDataSource”

autogeneratecolumns=“true” allowpaging=“false” runat=“server”> </asp:GridView> <asp:Button ID=“UpdateButton”

Text=“Refresh the Grid” runat=“server” /></asp:UpdatePanel>

Page 7: Module 1: Creating Responsive Pages with Ajax Creating Partial-Page Updates by Using AJAX Scripting Actions on the Web Client.

The ASP.NET AJAX Control Toolkit

•Shared source project between Microsoft and the ASP.NET AJAX community

•Downloadable from http://www.codeplex.com

•Contains a collection of templates and controls

•Provides an infrastructure to write reusable and extensible ASP.NET AJAX controls

Page 8: Module 1: Creating Responsive Pages with Ajax Creating Partial-Page Updates by Using AJAX Scripting Actions on the Web Client.

Lesson: Scripting Actions on the Web Client

•Improving Responsiveness by Creating Client-Side Scripts

•Creating Server-Side AJAX Services

•Calling Services from Client-Side Scripts

•Best Practices for Client-Side Scripting and AJAX

Page 9: Module 1: Creating Responsive Pages with Ajax Creating Partial-Page Updates by Using AJAX Scripting Actions on the Web Client.

Improving Responsiveness by Creating Client-Side Scripts

Page 10: Module 1: Creating Responsive Pages with Ajax Creating Partial-Page Updates by Using AJAX Scripting Actions on the Web Client.

Creating Server-Side AJAX Services

•Implementing a Server-Side Service as an ASP.NET Web Service

•Implementing a Server-Side Service as Page Methods

•Formats for Service Messages

Page 11: Module 1: Creating Responsive Pages with Ajax Creating Partial-Page Updates by Using AJAX Scripting Actions on the Web Client.

Calling Services From Client-Side Scripts

Adding Service References and Client-Side Script:

<asp:ScriptManager ID="ScriptManager1" runat="server"> <Services>

<asp:ServiceReference Path=“NewsWebService.asmx" />

</Services><Scripts>

<asp:ScriptReference Path=“NewsClientScript.js" />

</Scripts></asp:ScriptManager>

<asp:ScriptManager ID="ScriptManager1" runat="server"> <Services>

<asp:ServiceReference Path=“NewsWebService.asmx" />

</Services><Scripts>

<asp:ScriptReference Path=“NewsClientScript.js" />

</Scripts></asp:ScriptManager>

Calling a Service Function:

function GetNews()AdventureWorks.NewsWebService.GetNews(Succeeded)

function GetNews()AdventureWorks.NewsWebService.GetNews(Succeeded)

Page 12: Module 1: Creating Responsive Pages with Ajax Creating Partial-Page Updates by Using AJAX Scripting Actions on the Web Client.

Best Practices for Client-Side Scripting and AJAX

• Consider using AJAX whenever a small portion of a large page must refresh.

• Use the UpdatePanel to enable partial page updates without custom JavaScript code.

• Use the UpdateProgress control to reassure users when a partial page update takes time.

• Register client-side scripts with the AJAX client-side library to make use of AJAX extensions to JavaScript.

• Use AJAX services and custom JavaScript for optimum performance.

• Prevent use of the GET request verb in AJAX requests for increased security.

Page 13: Module 1: Creating Responsive Pages with Ajax Creating Partial-Page Updates by Using AJAX Scripting Actions on the Web Client.

Lab: Creating Responsive Pages by Using Client-Side Technologies

•Exercise 1: Implementing Partial-Page Updates by Using AJAX Controls

•Exercise 2: Accessing a Web Service by Using a Client Side Script

Estimated time: 60 minutes