18

Extending the Browser Programming Model with Silverlight

Embed Size (px)

DESCRIPTION

Learn how to extend your Web applications with Silverlight.

Citation preview

Page 1: Extending the Browser Programming Model with Silverlight
Page 2: Extending the Browser Programming Model with Silverlight

Extending the Browser Programming Model with SilverlightStefan SchackowProgram ManagerMicrosoft Corporation

Page 3: Extending the Browser Programming Model with Silverlight

Topics

Working with HTML and JavascriptCloser look at web servicesUsing isolated storageCreating a file upload application using OpenFileDialog

All samples can be downloaded at:• http://mixer1068.mixsandbox.com/

Page 4: Extending the Browser Programming Model with Silverlight

HTML Type HierarchySystem.Windows.Browser

HtmlObject

ScriptableObject

HtmlPage.Window

HtmlDocument HtmlElement

is an

Page 5: Extending the Browser Programming Model with Silverlight

Working with HTML

demo

Page 6: Extending the Browser Programming Model with Silverlight

Working with JavascriptAccessing managed code from Javascript

[Scriptable] enables non-visual use of managed code

Can create managed libraries"Reference" them on the page with a no-op xaml page and code-behind class

Future iterations will remove the need for a xaml type

Page 7: Extending the Browser Programming Model with Silverlight

Working with JavascriptAccessing managed code from Javascript

[Scriptable] managed typesProperties, methods and events accessible from JavascriptDynamically register endpoints using WebApplication

[Scriptable] endpoints hang off the "Content" control property

mySLControl.Content.MyCustomEndpoint.ManagedProperty

Type support in Silverlight AlphaInt, Double, String and ScriptableObjectUse JSON to pass complex types by value

Page 8: Extending the Browser Programming Model with Silverlight

Working with JavascriptAccessing managed code from Javascript

Using a [Scriptable] eventMake sure control is loadedAssign Javascript method to managed event propertyManaged code can then raise event back out to Javascript

Can use custom event argumentsDerive from EventArgsMark the type and one or more properties with [Scriptable]Allows managed code to call "arbitrary" Javascript methods

Page 9: Extending the Browser Programming Model with Silverlight

Using [Scriptable] endpoints

demo

Page 10: Extending the Browser Programming Model with Silverlight

Web servicesSilverlight Alpha works with:

ASP.NET AJAX 1.0 web services (as well as Orcas)

Works with JSON serializable typesPrimitives, string, arrays, DateTime, dictionaries, custom types, and collections of any of these typesCustom type serializers not tested for Alpha

Page 11: Extending the Browser Programming Model with Silverlight

Web servicesCustom slwsdl.exe proxy generator

"/silverlightclient" switch generates a Silverlight specific proxyProxy generator uses a custom System.Web.Services.dll

Custom SoapHttpClientProtocol type used by proxy

"POST" verbContent type set to "application/json"Parameters and return values serialized using JavaScriptSerializerSupports both sync and async models

Page 12: Extending the Browser Programming Model with Silverlight

Web ServicesCalling ASP.NET Application Services

Silverlight can consume JSON based app servicesNeed to manually generate proxy

Take an existing Silverlight web service proxyCopy the type definitionUpdate methods and Url to match app service method signatures

ASP.NET application service Urls are:Profile_JSON_AppService.axdAuthentication_JSON_AppService.axd

Page 13: Extending the Browser Programming Model with Silverlight

Using the profile web service

demo

Page 14: Extending the Browser Programming Model with Silverlight

Isolated Storage

Stream based access to a private file/directory structure

Will have easier accessors in following iterations

Patterned after .NET Framework IsolatedStorage classesRead and write string or binary dataFor Alpha you get an iso-store per Source attribute

contoso.com/foo.xaml and contoso.com/bar.xaml each get a different isostore1MB limit per iso-store

Same iso-store is across browsers

Page 15: Extending the Browser Programming Model with Silverlight

Isolated storage

demo

Page 16: Extending the Browser Programming Model with Silverlight

File upload application

demo

Page 17: Extending the Browser Programming Model with Silverlight

Please fill out your eval

evaluation

Page 18: Extending the Browser Programming Model with Silverlight

© 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions,

it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.