Blog

ASP.NET AJAX 4.0 and the ScriptManager Control

June 01, 2009 by Damien White

Puzzle Pieces

I have been using ASP.NET AJAX 4.0 quite a bit lately, as I’m sure most of you are aware from my recent posts. In those posts, I used standard HTML script references to show that ASP.NET AJAX is not reliant upon ASP.NET. I realize that many of you are in fact using ASP.NET, and today we will take a look at using the ScriptManager.

First we’ll look at using the Preview 4 scripts within an ASP.NET 3.5 application (with the ScriptManager of course) as well as using client templates and ADO.NET Data Services with the ScriptManager in ASP.NET 4.0 (Beta 1). After that, we’ll take a closer look at some of the new features of the ScriptManager in ASP.NET 4.0.

Preview 4 and the ASP.NET 3.5 ScriptManager

In my posts on ASP.NET AJAX 4.0 so far, I used standard HTML script references (as stated earlier). However, what if you wanted to incorporate the new ASP.NET AJAX 4.0 scripts with a ScriptManager. I tried this in a recent ASP.NET 3.5 SP1 project, and ran into some issues getting it all to work out. Thanks to this blog (and Bertrand LeRoy), I found the solution.

<asp:scriptmanager id="sm" runat="server">
    <scripts>
        <asp:scriptreference scriptmode="Inherit" name="MicrosoftAjax.js" path="~/scripts/MicrosoftAjax.js" />
        <asp:scriptreference scriptmode="Inherit" path="~/scripts/MicrosoftAjaxAdoNet.js" />
        <asp:scriptreference scriptmode="Inherit" path="~/scripts/MicrosoftAjaxTemplates.js" />
    </scripts>
</asp:scriptmanager>
Read More »

ASP.NET 4.0 AJAX – Preview 4 – Data Binding

May 27, 2009 by Damien White

Laptop

Throughout the course of my introductory posts on ASP.NET AJAX 4.0, we looked at the new DataView control as well as the Sys.Observer class, which brings the Observer pattern to plain JavaScript objects. The new ASP.NET AJAX release is very exciting offering powerful new features to take AJAX enabled applications to a new level. In this post, we’ll look at another exciting feature of ASP.NET AJAX 4.0 known as “live bindings.”

You may remember that we looked briefly at live bindings in the client templates post, but for those examples I used one-way / one-time bindings. Today, we’ll take a closer look at live bindings and see how two-way live bindings removes the one-way / one-time binding restriction allowing us to update bound elements on our page automatically when the underlying data changes.

Again, in this post, I’ll be using Preview 4 of the ASP.NET AJAX Library, which can be downloaded from CodePlex. The Preview 4 version can be used in your applications today (e.g. ASP 3.5, HTML). Keep in mind that these components are still in “preview” mode (meaning no Microsoft support), though they are usable at your own risk. For more information, you can check out the license on CodePlex.

Read More »

ASP.NET 4.0 AJAX – Preview 4 – JavaScript Observer Pattern

May 21, 2009 by Damien White

Examine

In my last post on ASP.NET AJAX 4.0, we took a look at the new DataView ASP.NET AJAX control. We saw that by using a DataView, we could easily bind data with JavaScript or declaratively with a few attributes. In this post, we’ll look at another feature of the ASP.NET 4.0 AJAX Library, the Observer design pattern for plain JavaScript objects. The pattern is implemented in the client side Sys.Observer class. This feature is used internally within the new version of ASP.NET AJAX for live-binding and the DataView control.

Here we will be using Preview 4 of the ASP.NET AJAX Library, which can be downloaded from CodePlex. Remember that these components are still in “preview” mode (meaning no Microsoft support), though they are usable at your own risk. For more information, you can check out the license on CodePlex. I highly recommend downloading the samples available for Preview 4, which are also available at CodePlex. The samples give you a good look at what is coming.

In this post, we’ll take a closer look at the Sys.Observer class, witness the problems it solves, and take a look at a few examples.

Read More »

How To: Adding MVC items to an ASP.NET Web Application

May 20, 2009 by Damien White

Code

I’ve been experimenting with using ASP.NET MVC inside a standard ASP.NET Web Application (Web Forms).  I really like what’s been released with MVC 1.0 and can see places where existing apps would benefit from the features.  Plus, having just finished Professional ASP.NET MVC 1.0 from Wrox (see my book review), I couldn’t wait to start using it.

The last chapter of the book, Chapter 12, entitled “Best of Both Worlds: Web Forms and MVC Together,” discusses configuring an ASP.NET Web Application to support the new ASP.NET MVC features.  Note that adding Web Forms to an ASP.NET MVC project template is much easier (meaning no configuration/reference changes), since ASP.NET MVC is built on top of the ASP.NET Framework.  Anyway, after referencing the required libraries, creating the necessary directories, and updating the web.config, you’ll find that templates for the MVC items (e.g. Controllers, Views), are missing as options.

Read More »

Book Review – Wrox Professional ASP.NET MVC 1.0

May 17, 2009 by Damien White

Professional ASP.NET MVC 1.0 Working primarily on web applications, I’ve focused most of my time on ASP.NET Web Forms since the very early betas. Web Forms were truly a great revolution in the web world. Once I saw the functionality when it first came out (when I was using ::shudder::  “classic” ASP), I couldn’t wait to start using it. I began right away with ASP+, as it was called back in 2000, abandoning Visual Interdev and ASP, yippee. The release of Version 1.0 came out January 16, 2002, changing the way we work with the web.

Flash-forward 7 years (9 from the early betas), and the programming world has changed. With things like TDD (Test Driven Development), AJAX, JSON, jQuery, etc, and the complexity of web applications growing, sometimes Web Forms would get in the way. To be fair, the Web Form framework is very robust and tries to be helpful, but sometimes we developers like to shoot ourselves in the foot. One example that I’m sure many of you have experienced is trying to interface with a server-rendered element on the page. Performing something like a document.getElementById(‘UserName’) in JavaScript doesn’t exactly work as expected when the ID of your textbox is now something along the lines of ctl00\_mainContent\_LoginCtrl_UserName, does it? On this particular topic, ASP.NET 4.0 has a solution for this problem, but that isn’t the focus of this post. The Client Id problem, is just one example of the framework “getting in your way.”  This is one of the many reasons behind the advent of ASP.NET MVC. Having just finished Professional ASP.NET MVC 1.0 from Wrox, I’m a convert.

Read More »

ASP.NET 4.0 AJAX - Preview 4 - Client Templates

April 28, 2009 by Damien White

Gears A little over a month ago, Microsoft released the fourth preview of ASP.NET 4.0 AJAX. This is the new release of the Microsoft AJAX Framework that will be released with ASP.NET 4.0. We’re getting closer to the RTM release of .NET 4.0 (hopefully later this year), so I figured this would be a good time to start posting about ASP.NET 4.0 AJAX. There are some very exciting things coming along with ASP.NET 4.0, and the ASP.NET AJAX component is no exception. The best news about ASP.NET AJAX is that you can start using it today without having to wait for the full blown ASP.NET AJAX framework. Keep in mind that these components are still in “preview” mode (meaning no Microsoft support), though they are usable at your own risk. For more information, you can check out the license on CodePlex.

In this post, I’ll be talking about the client templates that can be found in the latest release. Client templates are very powerful. They are a key component for rich client-side applications. Up until now, I have been using jTemplates, a client template solution plugin for jQuery. If you aren’t familiar with jTemplates, check out Dave Ward’s article “Use jQuery and ASP.NET AJAX to build a client side Repeater.” jTemplates is really a nice plugin, but it’s a bit disconnected from the flow of the page. Enter ASP.NET 4.0 AJAX and the DataView control.

Read More »

SQL Express 2008 x64 Integration with Visual Studio 2008 SP1

February 06, 2009 by Damien White

Yesterday I was trying to add a database to the App_Data folder of a simple web application I was creating. During one of my computer re-installs, I didn’t install SQL Express since I normally use a full blown SQL instance, so I really had no need for it. Now that I did need it, I wanted to run SQL Express 2008. I am running Windows Vista x64, so I proceeded to download SQL Express 2008 x64. I installed it and loaded up SQL Server Management Studio to make sure the instance was working (I just used the default of SQLEXPRESS for the instance name). Everything was fine. I then fired up Visual Studio, right-clicked on the App_Data folder of the web app, and… error (Figure 1).

Figure 01 Figure 1 – Connections to SQL require SQL Express

Read More »

My Wrox Blox Books – Now on Amazon!

January 30, 2009 by Damien White

I just happen to be browsing Amazon today and noticed that my Wrox Blox books are available for purchase on Amazon.com. Pretty cool stuff! They were listed up there before, but weren’t available directly through Amazon until now. For a full description and the table of contents of each, just click on the Amazon links at the bottom of this post. In addition, here are my previous announcements:

Both books are good guides for anyone using ASP.NET AJAX in either Visual Studio 2005 or 2008 using .NET 2.0 (with the AJAX Extensions) or .NET 3.5.

How To: Install Windows 7 on VirtualBox 2.1 – Fix Sound, Video and Network adapter

January 22, 2009 by Cedric Boudoya

On my previous blog posts, I covered the installation of VirtualBox 2.1 and I went over the step-by-steps to create a virtual machine to host Windows 7.

I will now go over the details of fixing the sound, video and network adapter.

If you go to Start > Right-click on My Computer > Manage (or run mmc), then you will get the content management window. You should notice that two devices are not properly installed (Base System Device, Ethernet Controller).

Figure 01

Read More »

How To: Install Windows 7 on VirtualBox 2.1 – Installation details

January 21, 2009 by Cedric Boudoya

On my previous blog posts, I cover the installation of VirtualBox 2.1 and I go over the step-by-steps to create a virtual machine to host Windows 7.

I will now go over the details to install Windows 7. Read More »