Today my publisher forwarded this great news:
The “.NET Daily Drawing” starts tomorrow, June 19
Tomorrow we are launching the ".NET Daily Drawing.” This promotion will run for one month, from June 19 - July 17. Each day’s lucky winner can choose one free .NET ebook of their choice. And finally, on the last day of the drawing, we're awarding one lucky winner...
...the entire Manning .NET library! (That’s nearly a $3000 value...)
If you love reading technical books, you can't miss this opportunity. Just click on this banner:

Today we published the source code for the book ASP.NET AJAX In Action on CodePlex. This means that you can always download the latest update by browsing to the Source Code page.
Our goal is to keep the source code in good shape as well as provide additional material. Go and tag/bookmark the project!
I've added a new article to my ASP.NET AJAX meets Virtual Earth series. This time we'll explore the inner workings of a Web Service proxy. If you are interested in the whole series, please check this post.
While searching for a free anti-spyware tool I found Google Pack, which is a suite of free applications that can be installed, updated and removed through a Google application. Give it a try.
Ajaxian has a blog post on Ajax Data Controls, an open source project supported by DotNetSlackers. I recommend to check it out, as it contains some really cool Ajax controls.
Are you based in Italy? If you're planning to attend the launch event for Visual Studio 2008, Sql Server 2008 and Windows Server 2008, be sure to check this post. You can also browse the Italian Heroes Happen website.
The errata for ASP.NET AJAX In Action has been posted on the Manning website.
Thanks for reporting issues and mistakes in the text! If you want to submit more, you can use the Online Author Forum.
This is a great start. I got the Microsoft MVP award for 2008!
Thanks to my MVP Lead Alessandro Teglia and to Microsoft for this great community recognition program.
If everything goes as expected, I will attend the MVP Summit this year.
Thanks!
Today DotNetSlackers published an article on the ASP.NET AJAX History feature, written by Dino Esposito.
The History functionality (that aims at solving the broken Back button issue) is included in the ASP.NET AJAX Extensions 3.5 package. The feature is now an integral part of ASP.NET AJAX and can be enabled through the ScriptManager control.
Previously, we had a separate History control that was included in the ASP.NET Futures package. History lovers (pun intended) can check this post by Nikhil Kothari. This is where it all begun.
Dave Ward setup a nice contest for his site's upcoming one year anniversary. It's an open drawing and you can win a copy of our book, ASP.NET AJAX In Action, by leaving a comment in the blog, subscribing via RSS or subscribing via email.
I highly recommend subscribing to Dave's blog. It's full of ASP.NET AJAX tricks and tips. (I've got it in my Google Reader list since a while.)
Good luck in the contest!
This post helps you understanding how the slider’s layout is structured and how to change the default appearance.
Layout
The Slider Extender replaces an extended asp:TextBox control with a graphical slider, as shown in figure 1.
Figure 1. Layout of the slider
As you can see from figure 1, the slider consists of an outer div element (in red) called the rail, and an inner div element (in green) called the handle. An img element nested in the handle div is used to display the handle’s image. This results in the following DOM hierarchy:
<div>
<div>
<img />
</div>
</div>
Default appearance
By default, the slider is rendered using default CSS classes for both the rail and the handle, as shown in figure 2.
Figure 2: Default appearance
The rail’s background image and the handle’s image are embedded as web resources in the AjaxControlToolkit assembly.
- A horizontal slider uses the .ajax__slider_h_handle and .ajax__slider_h_rail CSS classes for the handle and the rail, respectively.
- A vertical slider uses the .ajax__slider_v_handle and .ajax__slider_v_rail CSS classes for the handle and the rail, respectively.
Overriding the default CSS classes affects all the sliders hosted in a page.
When using the default theme, the only property that can be overridden on a per-slider basis is the slider’s length. This can be done by setting the Length property on the SliderExtender to an integer value.
At present, all the values are specified in pixels.
Now, let’s see how to customize the slider’s appearance.
Custom Appearance
In order to customize the slider’s appearance, we need to:
- Provide a CSS class for the rail
- Provide a CSS class for the handle
- Provide an image URL for the handle’s image.
Steps to perform:
1. Create a CSS class for the slider’s rail. The CSS class must contain the following attributes:
- The position attribute must be set to relative.
- Default values for height and width attributes must be provided. The width value can be overridden through the Length property of the SliderExtender.
- To embed a background image for the rail, use the background attribute.
2. Create a CSS class for the slider’s handle. The CSS class must contain the following attributes:
- The position attribute must be set to absolute.
- Values for height and width attributes must be provided.
3. Provide an image for the slider’s handle. The height and width sizes of the image must be equal to the height and width values specified in the handle’s CSS class.
4. Set the RailCssClass property of the SliderExtender instance to the name of the rail CSS class.
5. Set the HandleCssClass property of the SliderExtender instance to the name of the handle CSS class.
6. Set the HandleImageUrl property of the SliderExtender instance to the URL of the handle’s image.
Figure 3 shows a customized slider.
Figure 3: Custom appearance
The slider in figure 3 has been declared as follows:
<asp:TextBox ID="Slider" runat="server"></asp:TextBox>
<ajaxToolkit:SliderExtender ID="SliderExtender1" runat="server"
TargetControlID="Slider"
RailCssClass="slider_rail"
HandleCssClass="slider_handle"
HandleImageUrl="slider_custom_handle.png"
/>
The CSS classes for the slider’s rail and handle are defined like so:
.slider_rail {
position: relative;
height: 15px;
width: 200px;
background: #FFFFFF url(slider_custom_rail.png) repeat-x;
}
.slider_handle {
position: absolute;
height: 14px;
width: 22px;
}
Note that the default value of 200px set for the width attribute in the rail CSS class can be overridden through the Length property of the SliderExtender. As usual, the height and width attributes are swapped when dealing with vertical sliders.
A few days ago I've been invited to join ASPInsiders. I can't wait to share thoughts and ideas with so many great ASP.NET developers.
Thanks guys!
Back to writing time, we had the great pleasure of having Joe Stagner as the technical reviewer for our book ASP.NET AJAX In Action.
Now Joe is publishing some book excerpts on his blog, which is also linked from the ASP.NET homepage.
The first excerpt is taken from chapter 7, where we talk about the inner workings of the UpdatePanel and the PageRequestManager. The excerpt covers how to build a viewer to explore the events raised by the PageRequestManager, which is the component that takes care of the partial rendering mechanism on the client side.
More excerpts to come!
P.S. You can download here the whole source code for the book examples.
When dealing with partial postback scenarios, it's sometimes desirable to run some JavaScript at the end of a partial postback. A typical situation is when we inject the JavaScript code on the server side during a partial postback. The safest way is executing the client code while handling the Sys.Application.load event or the Sys.WebForms.PageRequestManager.endRequest event.
One drawback of this approach is that the injected handler will keep being executed on each partial postback, until the whole page is refreshed.
A solution would be to remove the handler as soon as it's been called. For example, this is the approach used by the Ajax Control Toolkit's ModalPopup extender to keep the popup visible after a postback.
To do that, we can use the ScriptManager.RegisterStartupScript method to inject some JavaScript code similar to the following:
(function() {
var f = function() {
// TODO: add code to execute after the
// partial posback.
Sys.Application.remove_load(f);
}
Sys.Application.add_load(f);
})();
In the previous code, the outer function adds the inner function (saved to the f variable) as an handler for the Sys.Application.load event.
Inside the inner function, we execute the desired code and then remove the handler. This is possible because, thanks to closures, we are able to access the f variable defined in the outer function. As said, this variable holds a reference to the handler.
Finally, the outer function will be called as soon as our script code is parsed.