08.01.2015 Views

Beginning Web Development, Silverlight, and ASP.NET AJAX

Beginning Web Development, Silverlight, and ASP.NET AJAX

Beginning Web Development, Silverlight, and ASP.NET AJAX

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 10 ■ .<strong>NET</strong> 3.0: PROGRAMMING WITH CARDSPACE 247<br />

The Use Card! button is defined with this markup:<br />

<br />

Use Card!<br />

Upon clicking the button, the JavaScript function GoGetIt is invoked. Here’s the<br />

function:<br />

function GoGetIt()<br />

{<br />

var xmltkn=document.getElementById("_xmltoken");<br />

var thetextarea = document.getElementById("xmltoken");<br />

thetextarea.value = xmltkn.value ;<br />

}<br />

This script uses the element _xmltoken to get its value <strong>and</strong> load that into a var that will<br />

fill a text box on the page. The _xmltoken field is a CardSpace object, whose definition looks<br />

like this:<br />

<br />

<br />

<br />

<br />

This is how you use CardSpace on a page—by declaring an object of type<br />

application/x-informationcard <strong>and</strong> naming it. There are a number of properties supported<br />

by this object, including the facility to specify the data that’s required by the site.<br />

Remember the earlier example in which the last name, first name, <strong>and</strong> so on were<br />

required data from the site—it is the requiredClaims property that dictates this. As you<br />

can see, it contains a list of the schemas of the required values.<br />

When you query its value property, the object invokes the CardSpace client <strong>and</strong><br />

allows you to specify a card. Should you specify <strong>and</strong> send a card, the value will become<br />

the token associated with that card; otherwise it will be null. The JavaScript code then<br />

loads the value of the token into the hidden text field xmltoken.<br />

Next, when the user clicks “Sign in now!” they are in fact invoking a st<strong>and</strong>ard HTML<br />

form whose action is the SignedIn.aspx page, <strong>and</strong> one of whose elements is the hidden<br />

text field. This causes the token to be submitted to SignedIn.aspx from where it can be<br />

parsed.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!