Book Image

MCTS: Microsoft Silverlight 4 Development (70-506) Certification Guide

By : Johnny Tordgeman
Book Image

MCTS: Microsoft Silverlight 4 Development (70-506) Certification Guide

By: Johnny Tordgeman

Overview of this book

Microsoft Silverlight is a powerful development platform for creating engaging, interactive applications for many screens across the Web, desktop, and mobile devices. Silverlight is also a great (and growing) Line-Of-Business platform and is increasingly being used to build data-driven business applications. Silverlight is based on familiar .NET languages such as C# which enables existing .NET developers to get started developing rich internet applications almost immediately. "MCTS: Microsoft Silverlight 4 Development (70-506) Certification Guide" will show you how to prepare for and pass the (70-506): TS: Microsoft Silverlight 4 Development exam.Packed with practical examples and Q&As, MCTS: Microsoft Silverlight 4 Development (70-506) Certification Guide starts by showing you how to lay out a user interface, enhance the user interface, implement application logic, work with data and interact with a host platform amongst others.
Table of Contents (15 chapters)
MCTS: Microsoft Silverlight 4 Development (70-506) Certification Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface

Interacting with the DOM


When hosted in a browser, Silverlight is a part of the page, the same as any other HTML object in it, so it's only fair that Silverlight will be able to interact with the different elements on the page. Meet the System.Window.Browser namespace. It will be your starting point for communicating with the HTML DOM. The namespace exposes different methods for accessing cookies and query strings, calling the JavaScript functions, and even manipulating the DOM elements.

Accessing cookies and query strings

We all know (and some of us love) HTML cookies, which are those little text nuggets that the browser saves on the user's computer and are mostly used for authentication, session tracking, and so on. Well, the good news is that you can access and save cookies using Silverlight as well.

Saving a cookie is a simple matter of calling the SetProperty method of the HtmlPage class's Document object with a string in the following format:

Key=Value;expires=ExpireDate

The following...