# Monday, 19 October 2009

I noticed that Visual Studio 2010 Beta 2 got out for MSDN subscribers today. It’ll be available for the rest of the world on October 23rd. Also good news: next year on March 22 it’ll be there in RTW status.

Also the new version doesn’t use the standard logo with the 4 colors again but is now a smooth looking purple/blue logo.

VS2010B2Installation

Grz, Kris.

Monday, 19 October 2009 20:41:41 (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Friday, 07 August 2009

You can grab the good stuff here.

Included is:

The Windows 7 Training Kit for Developers includes presentations, hands-on labs, and demos. This content is based on Windows 7 RTM and it is designed to help you learn how to build applications that are compatible with and shine on Windows 7 by utilizing key Windows 7 features such as:

  • Taskbar
  • Libraries
  • Multi Touch
  • Sensors and Location
  • Ribbon
  • Trigger Start Services
  • Instrumentation and ETW
  • Application Compatability
And Application Compatibility topics such as:
  • Version Checking
  • UAC Data Redirection
  • Session 0 Isolation
  • Installer Detection
  • User Interface Privilege Isolation
  • High DPI

Grz, Kris.

Friday, 07 August 2009 22:55:54 (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [1]  | 
# Friday, 31 July 2009

Great news for the ASP.NET MVC fans. After a release of MVC 1 earlier this year today the first preview of version 2 has been placed on the download servers.

Here are the announcements of Scott Guthrie and Phil Haack.

Grz, Kris.

Friday, 31 July 2009 09:21:35 (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Monday, 27 July 2009

Since more and more people are using ajax and as such javascript/ecmascript, you as a developer/designer need tools to make it through the day. Here are some that I like to use:

Grz, Kris.

Monday, 27 July 2009 09:16:03 (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Tuesday, 14 July 2009

Since WPF and especially Silverlight, since version 3 recently was released, have similarities it’s nice to have an overview of what both technologies have to offer and where Silverlight’s left out on certain things. I found such an overview on Codeplex: http://wpfslguidance.codeplex.com/.

Taken from the project description:

WPF and Silverlight are both XAML based platforms but there are some important functionality and implementation differences between the two. This project contains content illustrating these differences and the best practices for developing against these platforms.
Content posted to this project includes a whitepaper detailing what is similar and different between the two platforms as well as how to code against both platforms getting as much code reuse as possible.

Grz, Kris.

Tuesday, 14 July 2009 12:00:24 (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Monday, 13 July 2009

Going on vacation to Greece without pc or internet connection (but in very good company) is nice but you always find when coming home that new cool things have arrived. This time it turned out to be the long awaited Silverlight 3.

There’s an interesting video on Channel 9 with Scott Guthrie on the new things that shipped and also a new dedicated site. Be sure to check these out.

With the new version there’s also need of a tool to build compelling RIAs with. This is still in Release candidate but you can already check out Blend 3.

Grz, Kris.

Monday, 13 July 2009 18:02:28 (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Tuesday, 30 June 2009

Strange but true but this is a question that I notice a lot on forums.asp.net. Normally the latest and most up to date version can be found at http://ajaxcontroltoolkit.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=27326 like I described in one of my former blog posts.

How great Codeplex may be it seems that it’s difficult for a lot of people to find the correct version that targets ASP.NET 2.0. If you’re one of these people whose looking for it then navigate to this url: http://www.codeplex.com/AjaxControlToolkit/Release/ProjectReleases.aspx?ReleaseId=11121. As you can see there haven’t been updates out anymore for .NET 2.0 since February 29th 2008.

Update: apparently I already blogged about this in the past: ASP.NET AJAX Control Toolkit only for 3.5 anymore? Seems to me like still not a lot of people can find it.

Grz, Kris.

Tuesday, 30 June 2009 20:18:57 (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Monday, 29 June 2009

I’ve seen questions about this control over and over again on the forums and decided to write something about it. The most common questions seem to be these:

1) How to show the modalpopup from codebehind?

Quite an easy one. The control itself exposes a Show method. This can be called during a postback for example to show some informative message or to provide a fill in form for an enduser. The following code snippet show how to do it:

e Language="C#" AutoEventWireup="true" CodeBehind="ModalpopupShowFromCodeBehind.aspx.cs" Inherits="WebApplication35Tech.ModalPopupTesting.ModalpopupShowFromCodeBehind" %>
<%@ Register TagPrefix="act" Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Show a modalpopupextender from codebehind</title>
    <style type="text/css">

    .modalBackground {
        background-color:Gray;
        filter:alpha(opacity=70);
        opacity:0.7;
    }

    .modalPopup {
        background-color:#ffffdd;
        border-width:3px;
        border-style:solid;
        border-color:Gray;
        padding:3px;
        width:250px;
    }

    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="Scriptmanager1" runat="server" />
        
        <asp:Panel ID="pnlOverlay" style="display:none;" runat="server" CssClass="modalPopup">
            Some informative message: Hello world!
        </asp:Panel>
        
        <asp:Button ID="Button1" Text="Click me" runat="server" 
            onclick="Button1_Click" />
        
        <act:ModalPopupExtender runat="server" ID="mpe" 
            PopupControlID="pnlOverlay" 
            BackgroundCssClass="modalBackground" 
            TargetControlID="pnlOverlay"></act:ModalPopupExtender>
    </div>
    </form>
</body>
</html>

And the codebehind:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication35Tech.ModalPopupTesting
{
    public partial class ModalpopupShowFromCodeBehind : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            mpe.Show();
        }
    }
}

 

This little sample, once the button is clicked and a postback has occured, will lay a so called overlay over the content of the page and in the middle of the screen will show what’s inside pnlOverlay.
Notice that I put the style=”display:none;” in the panel markup. This was done to initially hide the content. Otherwise you get the behavior that the content of the overlay will show on rendering in the browser in the top left corner and then suddenly flashes to the center of the screen which is rather unwanted behavior.

2) How to show the modalpopup from script?

This seems to be a bit more tricky. The modalpopup extender control has an ID and most people seem to the think that this should be used in client script to show it. As many have found out this is incorrect. Besides the ID of an extender it also provides a BehaviorID. This is the one that can be used to for example show our modal popup or to set the value of a slider extender (also a part of the ASP.NET Ajax control toolkit).

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ModalpopupShowFromClientScriptWithjQuery.aspx.cs" Inherits="WebApplication35Tech.ModalPopupTesting.ModalpopupShowFromClientScriptWithjQuery" %>
<%@ Register TagPrefix="act" Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Show a modalpopupextender from client script</title>
    <style type="text/css">

    .modalBackground {
        background-color:Gray;
        filter:alpha(opacity=70);
        opacity:0.7;
    }

    .modalPopup {
        background-color:#ffffdd;
        border-width:3px;
        border-style:solid;
        border-color:Gray;
        padding:3px;
        width:250px;
    }

    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
                <asp:ScriptManager ID="Scriptmanager1" runat="server" />
        
        <asp:Panel ID="pnlOverlay" style="display:none;" runat="server" CssClass="modalPopup">
            Some informative message: Hello world!
        </asp:Panel>
        
        <input type="button" id="MyButton" value="Click me" />
        
        <act:ModalPopupExtender runat="server" ID="mpe" 
            PopupControlID="pnlOverlay" 
            BackgroundCssClass="modalBackground" 
            TargetControlID="pnlOverlay"
            BehaviorID="mpeBehaviorID"></act:ModalPopupExtender>
    </div>
    </form>
    <script src="../scripts/jquery-1.3.2.js" type="text/javascript"></script>
    <script type="text/javascript">

        window.onload = function() { $addHandler($get('MyButton'), 'click', showOverlay); }

        function showOverlay() {
            var bid = $find('mpeBehaviorID');
            bid.show();
        }
    
    </script>
</body>
</html>

 

For this sample I made use of the unobtrusive way of capturing a click event of a button. Here I use ASP.NET Ajax to wire up the click event of the button in the onload event of the page. but I could’ve also written the same with jQuery. Note that I’m then mixing 2 different javascript frameworks/libraries together! That little piece of script looks like this:

$(document).ready(function() {
    $('#MyButton').click(function() {
        var bid = $find('mpeBehaviorID');
        bid.show();
    });
});

Once the button is clicked the overlay will show itself.

3) How to reposition the modalpopup?

As we saw in the previous 2 samples the modalpopup shows itself in the center of the screen. Nice but sometimes you want to place it somewhere different. This can be done by using the setLocation function from ASP.NET Ajax. A sample will make it more clear:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ModalpopupChangeScreenPosition.aspx.cs" Inherits="WebApplication35Tech.ModalPopupTesting.ModalpopupChangeScreenPosition" %>
<%@ Register TagPrefix="act" Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Reposition a modalpopup</title>
    <style type="text/css">

    .modalBackground {
        background-color:Gray;
        filter:alpha(opacity=70);
        opacity:0.7;
    }

    .modalPopup {
        background-color:#ffffdd;
        border-width:3px;
        border-style:solid;
        border-color:Gray;
        padding:3px;
        width:250px;
    }

    </style>
    <script type="text/javascript">
    
        function pageLoad() {
            $addHandler($get('btn1'), 'click', reposition);
            $addHandler($get('link2'), 'click', showModalPopupViaClient);
        }
        function reposition(ev) {
            ev.preventDefault();
            var posP = Sys.UI.DomElement.getLocation($get('testLocation'));
            var posPnl = Sys.UI.DomElement.getLocation($get('Pnl3'));
            Sys.UI.DomElement.setLocation($get('Pnl3'), posPnl.x, posP.y);
        }
        function showModalPopupViaClient(ev) {
            if (ev !== undefined) {
                ev.preventDefault();
            }
            var modalPopupBehavior = $find('test');
            modalPopupBehavior.show();
            
            var posP = Sys.UI.DomElement.getLocation($get('link2'));
            var posPnl = Sys.UI.DomElement.getLocation($get('Pnl3'));
            
            Sys.UI.DomElement.setLocation($get('Pnl3'), posPnl.x, posP.y);
        }
    
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager runat="server" ID="sm"></asp:ScriptManager>
        <asp:Panel runat="server" ID="Pnl3">
            <asp:TextBox runat="server" ID="txtTest"></asp:TextBox><br />
            <asp:Button runat="server" ID="btn1" Text="Reposition" />
        </asp:Panel>
        <asp:LinkButton runat="server" ID="link1" Text="Click me..."></asp:LinkButton>
        
        <act:ModalPopupExtender runat="server" ID="modal1" PopupControlID="Pnl3"
            TargetControlID="link1" BackgroundCssClass="modalBackground" RepositionMode="None"
            Y="80" BehaviorID="test">
        </act:ModalPopupExtender>
        
        <p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>
        <p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>
        <p id="testLocation">test...</p>
        <p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>
        <p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>
        <input type="button" id="link2" value="Click me too..." />
    </div>
    </form>
</body>
</html>

Once rendered there’s a link at the top and a button on the bottom of the page. Either one can be clicked and because we wired up the event handlers (with the $addHandler shortcut provided by ASP.NET Ajax) the function showModalPopupViaClient gets called. This once again grabs the BehaviorID, mind the sample in point number 2. Once done it grabs several coordinates with the Sys.UI.DomElement.getLocation function call. Then it uses the x position of the panel that acts as the modalpopup and the y position of the button.

However we notice something strange here. When we click the button on the bottom we expect that the overlay is set to the bottom as well due to the x/y positioning. But when we click the link in the left top corner we would expect that it would center as we didn’t add a handler for that click right? This isn’t the case. The modalpopup becomes visible near the top. How is this done? Well, notice in the markup of the modalpopupextender the attribute Y=”80”. This is what makes it all happen. It’s our default position to show the modalpopup.

Once the popup has appeared we can simply click the button Reposition. The function reposition will get called and the modalpopup will reposition itself to the y position of the paragraph with id=testLocation.

 

Grz, Kris.

Monday, 29 June 2009 22:39:40 (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [1]  | 
# Sunday, 07 June 2009

The first time I encountered .NET Reflector was at Techdays Belgium in 2003 during a session. I got interested in this valuable tool and used it ever since for disassembling .NET assemblies to code and take a look at the inner workings. If you haven’t downloaded it already then you can grab it here.

A little known fact is that one can also extract embedded resources with this marvelous tool. When you simply open .NET reflector like in figure 1 you can navigate in the treeview to System.Web > Resources.

reflector01 
Figure 1: .NET Reflector assemblies overview

Then scroll down until you find the resource with the name WebUIValidation.js. Right click on it and select Save As… like in figure 2:

reflector02
Figure 2: Save the resource.

After this action a Filesavedialog window will open so you can save the resource to disk.

 

Also be sure to check out this demo movie from Redgate itself which shows some nice standard features if you’re not used to working with the product.

Grz, Kris.

Sunday, 07 June 2009 22:55:00 (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [1]  | 
# Monday, 01 June 2009

I recently read the book ASP.NET MVC Quickly from Maarten Balliauw, published by PACKT Publishing. It’s been one of those few books that I read from cover to cover. Not only because the subject interested me but also because it shows in about 190+ pages an introduction to this new technology from Microsoft. It was clear that the person who wrote it knows quite a lot about the subject and that shows in the book. I really appreciated Appendix A and C where Maarten discusses a sample application he created: CarTrackr.

aspnetmvcquickly

 

Chapters 1 & 2 provide some quick introductions as to how the architecture looks like and why you would use it over normal ASP.NET webforms. Provided is a “litmus” test to see whether to go for MVC or Webforms and discusses the advantages of both. Chapter 2 explains what’s in the box when you create a new ASP.NET MVC application with Visual Studio. Also a first small application’s being built with ViewData and strong typed ViewData.

Chapter 3 introduces you to a simple application, shows how to deal with fileuploads in MVC, simple validation and the creation of a custom ModelBinder attribute.

Chapter 4 covers the ASP.NET MVC request life cycle. Yes there’s a life cycle but not similar to the ASP.NET Page Life Cycle most people got to know during the last years. After that it proceeds with a more in depth look at the model and validation on such a model. After that an in depth look at controllers, actionresult types and how to handle unknown controller actions. Master pages and Partial views (.ascx) are covered. Those last are only briefly touched and I found that a bit of a pity as these are important concepts. Especially the lack of nester master pages in this story was something I missed.

Chapter 5 is totally dedicated to routing. A very important concept in the whole ASP.NET MVC technology stack (and ASP.NET Dynamic Data and also possible to use with normal webforms). Also a quick explanation on how to integrate both ASP.NET and ASP.NET MVC together in the same project routing wise.

Chapter 6 shows you an overview on how to customize the framework and to even build a small custom viewengine. Also the making of a custom ActionFilter gets discussed.

Chapter 7 shows how to use the standard membership, session state, … that we all know from webforms in ASP.NET MVC. After all, it’s built on top of normal ASP.NET so they can share a great deal of the standard technology. Also is shown how to integrate both technology stacks in the same project. This can be interesting food for thought when people want to gradually upgrade to MVC. Also a nice trick to build views at compile time. Slowing the process down but can safe time in finding out the hard way that you forgot a ) or something and the whole thing explodes in your face.

The next chapter tells us more about AJAX. I had hoped to see this chapter to be longer but it just gives a quick overview. The fact that both ASP.NET AJAX and jQuery (even some of the ui components) are discussed is a plus. I’m a big fan of the latter myself.

Then chapter 9’s all about testing. Also mocking’s discussed. Since ASP.NET MVC is also considered to be way better than webforms to be tested (TDD and such) this is an interesting chapter.

The last chapter is all about deployment; A lot of resources seem to be forgetting about this but I liked the fact that this book covers it. Also on older versions of IIS than 7.

As already stated above, I liked appendix A and C. They cover an application built with the technology which is downloadable on codeplex. Appendix C provides an overview of very interesting resources about the topic.

Conclusion: it’s a nice book that quickly gets a developer into the terms of ASP.NET MVC, covers quite a lot of ground and touches the interesting parts of the technology. Some parts I would’ve loved to see a bit deepened out, especially the parts about the master pages and partial views as well ajax. On the other hand I read it from cover to cover and that certainly means something.

Grz, Kris.

Monday, 01 June 2009 21:06:19 (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  |