Gunnar Peipman's ASP.NET blog

ASP.NET, C#, SharePoint, SQL Server and general software development topics.






March 2011 - Posts

Webcast: Brief introduction to Windows Identity Foundation

This is my first webcast on Windows Identity Foundation (WIF) and it will give you brief overview of this technology. I will tell you about how I found WIF, what is claims-based authentication, what tools are available and how you can use WIF in your systems. This is no-code overview and you can expect demos and code from my next WIF webcasts.

NB! This is my first webcast I have ever made so please forgive me if it is not as professional as you may expect. I hope you will still enjoy it :)

If you cannot see video then click here: Windows Identity Foundation - Part I: Introduction


I would really appreciate if you give me feedback about this webcast. All feedback – positive or negative – is very welcome as I really want to improve my skills on making great webcasts. Feel free to leave me your feedback here as comments of this post.


Here you can find resources related to my Windows Identity Foundation series.

powerpoint_32x32 Presentation slides
PowerPoint 2010 | 1453 KB




Book Review: Programming Windows Identity Foundation
Programming Windows Identity Foundation
Programming Windows Identity Foundationalt

Programming Windows Identity Foundation by Vittorio Bertocci is right now the only serious book about Windows Identity Foundation available.

I started using Windows Identity Foundation when I made my first experiments on Windows Azure AppFabric Access Control Service. I wanted to generalize the way how people authenticate theirselves to my systems and AppFabric ACS seemed to me like good point where to start. My first steps trying to get things work opened the door to whole new authentication world for me. As I went through different blog postings and articles to get more information I discovered that the thing I am trying to use is the one I am looking for.

As best security API for .NET was found I wanted to know more about it and this is how I found Programming Windows Identity Foundation.

What’s inside?

Programming WIF focuses on architecture, design and implementation of WIF. I think Vittorio is very good at teaching people because you find no too complex topics from the book. You learn more and more as you read and as a good thing you will find that you can also try out your new knowledge on WIF immediately.

After giving good overview about WIF author moves on and introduces how to use WIF in ASP.NET applications. You will get complete picture how WIF integrates to ASP.NET request processing pipeline and how you can control the process by yourself. There are two chapters about ASP.NET. First one is more like introduction and the second one goes deeper and deeper until you have very good idea about how to use ASP.NET and WIF together, what issues you may face and how you can configure and extend WIF.

Other two chapters cover using WIF with Windows Communication Foundation (WCF) band   Windows Azure. WCF chapter expects that you know WCF very well. This is not introductory chapter for beginners, this is heavy reading if you are not familiar with WCF. The chapter about Windows Azure describes how to use WIF in cloud applications.

Last chapter talks about some future developments of WIF and describer some problems and their solutions. Most interesting part of this chapter is section about Silverlight.

Who should read this book?

Programming WIF is targeted to developers. It does not matter if you are beginner or old bullet-proof professional – every developer should be able to be read this book with no difficulties. I don’t recommend this book to administrators and project managers because they find almost nothing that is related to their work.

I strongly recommend this book to all developers who are interested in modern authentication methods on Microsoft platform. The book is written so well that I almost forgot all things around me when I was reading the book. All additional tools you need are free. There is also Azure AppFabric ACS test version available and you can try it out for free.

Table of contents



Part I Windows Identity Foundation for Everybody
1 Claims-Based Identity
2 Core ASP.NET Programming

Part II Windows Identity Foundation for Identity Developers
3 WIF Processing Pipeline in ASP.NET
4 Advanced ASP.NET Programming
5 WIF and WCF
6 WIF and Windows Azure
7 The Road Ahead


ASP.NET: Building tree picker dialog using jQuery UI and TreeView control

Selecting things from dialogs and data represented as trees are very common things we see in business applications. In this posting I will show you how to use ASP.NET TreeView control and jQuery UI dialog component to build picker dialog that hosts tree data.

Source code

You can find working example with source code from my examples repository in GitHub. Please feel free to give me feedback about my examples.

Source code @ GitHub Source code repository

Building dialog box

As I don’t like to invent wheels then I will use jQuery UI to solve the question related to dialogs. If you are not sure how to include jQuery UI to your page then take a look at source code - GitHub also allows you to browse files without downloading them.

I add some jQuery based JavaScript to my page head to get dialog and button work.

<script type="text/javascript">
    $(function () {

() {
return false

Here is the mark-up of our form’s main content area.

<div id="dialog-form" title="Select node">
    <asp:TreeView ID="TreeView1" runat="server" ShowLines="True"

ClientIDMode="Static" HoverNodeStyle-CssClass="SelectedNode">
            <asp:TreeNode Text="Root"
                <asp:TreeNode Text="Child1" Value="Child1">
                    <asp:TreeNode Text="Child1.1" Value="Child1.1" />
                    <asp:TreeNode Text="Child1.2" Value="Child1.2" />
                <asp:TreeNode Text="Child2" Value="Child2">
                    <asp:TreeNode Text="Child2.1" Value="Child2.1" />
                    <asp:TreeNode Text="Child2.2" Value="Child2.2" />
<button id="pick-node">Pick user</button>

Notice that our mark-up is very compact for what we will achieve. If you are going to use it in some real-world application then this mark-up gets even shorter – I am sure that in most cases the data you display in TreeView comes from database or some domain specific data source.

Hacking TreeView

TreeView needs some little hacking to make it work as client-side component. Be warned that if you need more than I show you here you need to write a lot of JavaScript code. For more advanced scenarios I suggest you to use some jQuery based tree component. This example works for you if you need something done quickly.

Number one problem is getting over the postbacks because in our scenario postbacks only screw up things. Also we need to find a way how to let our client-side code to know that something was selected from TreeView.

We solve these to problems at same time: let’s move to JavaScript links. We have to make sure that when user clicks the node then information is sent to some JavaScript function. Also we have to make sure that this function returns something that is not processed by browser. My function is here.

<script type="text/javascript">
selectNode(value, text) {
"You selected: " + value + " - "
+ text);

Notice that this function returns undefined. You get the better idea why I did so if you look at server-side code that corrects NavigateUrl properties of TreeView nodes.

protected override void OnPreRender(EventArgs e)


private void SetSelectNodeUrls(TreeNodeCollection
foreach (TreeNode node in
        node.NavigateUrl =
+ node.Value +
"','" + node.Text + "');"

Now we have TreeView that renders nodes the way that postback doesn’t happen anymore. Instead of postback our callback function is used and provided with selected values. In this function we are free to use node text and value as we like.


I applied some more bells and whistles and sample data to source code to make my sample more informative. So, here is my final dialog box.

jQuery Tree Picker Dialog

Seems very basic but it is not hard to make it look more professional using style sheets.


jQuery components and ASP.NET controls have both their strong sides and weaknesses. In this posting I showed you how you can quickly produce good results when combining jQuery  and ASP.NET controls without pushing to the limits. We used simple hack to get over the postback issue of TreeView control and we made it work as client-side component that is initialized in server. You can find many other good combinations that make your UI more user-friendly and easier to use.

More Posts