The blog of dlaa.me

ASP.NET AJAX 1.0 is on the loose! [AJAX Control Toolkit update!]

Earlier today we made available the 10123 release of the AJAX Control Toolkit. We did this in parallel with the official release of ASP.NET AJAX v1.0 and added a bunch of good stuff along the way.

As I note in the release teaser, "This release of the AJAX Control Toolkit includes four new controls (AutoComplete (formerly in the Futures CTP), Calendar, MaskedEdit, and Tabs), fixes for over 75 issues reported by the community, and new functionality for ModalPopup, RoundedCorners, and the ExtenderBase framework." Additionally, we spent time making sure that all 32 Toolkit controls work well on the latest version of the Opera browser. Accepting that every browser has its little quirks, we now offer the same level of "pretty much everything works" support for Internet Explorer 6, Internet Explorer 7, Firefox 1.5, Firefox 2.0, Safari 2.0.4, and Opera 9.10. Those are the top six browsers on the Internet, so there's an very good chance that visitors to a Toolkit-enabled site will be running a supported browser.

Of note, three of the four new controls for this release were submitted by contributors! Ron Buckton wrote both Calendar and Tabs while Fernando Cerqueira wrote MaskedEdit. These are some very cool new controls and we're fortunate to have such great contributors helping out with the Toolkit! As a teaser, I created two little "movies" to show off Calendar and MaskedEdit in action - as well as our Opera support. :)

Calendar Demonstration

MaskedEdit Demonstration

Recall that you can sample any of the controls right now (no install required). You can also browse the project web site, download the latest Toolkit, and start creating your own controls and/or contributing to the project!

If you have any feedback, please share it with us on the support forum (or email me)!

Runnin' on the RC [AJAX Control Toolkit update!]

A few minutes ago we made available the 61214 release of the AJAX Control Toolkit. We did this in parallel with the release of the ASP.NET AJAX v1.0 RC in order to accommodate some breaking changes introduced in that release. Though we did not make any functional changes to the Toolkit in this release, we did take the opportunity to fix a handful of bugs that we'd found.

Recall that you can sample any of the controls right now (no install required). Then you can browse the project web site, download the latest Toolkit, and start creating your own controls and/or contributing to the project!

If you have any feedback, please share it with us on the support forum (or email me)!

Dynamic content made easy *remix* [How to: Use the new dynamic population support for Toolkit controls]

I previously blogged an update to my sample demonstrating how to use the AJAX Control Toolkit's dynamic population functionality with a data-bound ModalPopup. Someone asked privately what the C# page method would look like in VB, so I figured I'd post a small follow-up to show the straightforward translation to VB.

Here's the original C# code for reference:

<script runat="server">
[System.Web.Services.WebMethod]
[Microsoft.Web.Script.Services.
ScriptMethod]
public static string GetContent(string contextKey)
{
    
// Create a random color
    string color = (new Random()).Next(0xffffff).ToString("x6");
    
// Use the style specified by the page author
    string style = contextKey;
    
// Display the current time
    string time = DateTime.Now.ToLongTimeString();
    
// Compose the content to return
    return "<span style='color:#" + color + "; " + style + "'>" + time + "</span> ";
}
</script>

Translating that to VB is largely a matter of changing the syntactic elements from their C# versions to their VB versions. So "[" becomes "<", "}" becomes "End Function", and so on... Two things that tripped me up because I don't regularly use VB were the translation of the hexadecimal prefix "0x" to "&H" and the translation of "static" to "Shared" - but a quick look at the online documentation for VB sorted me out on both counts. After a short while, I ended up with this:

<script runat="server">
    <System.Web.Services.WebMethod()> _
    <Microsoft.Web.Script.Services.ScriptMethod()> _
    
Public Shared Function GetContent(ByVal contextKey As String) As String
        ' Create a random color
        Dim color As String = (New Random()).Next(&HFFFFFF).ToString("x6")
        
' Use the style specified by the page author
        Dim style As String = contextKey
        
' Display the current time
        Dim time As String = DateTime.Now.ToLongTimeString()
        
' Compose the content to return
        Return "<span style='color:#" + color + "; " + style + "'>" + time + "</span> "
    End Function
</
script>

I completed the translation by changing the sample page's Page/Language property from "C#" to "VB", ran the sample page, and verified that it worked just like it did before. Of course! :)

Another quick, small-scale release [AJAX Control Toolkit update!]

Just a short while ago we made available the 61121 release of the AJAX Control Toolkit. I'd barely finished posting the release bits to CodePlex and was still in the process of verifying them when I saw that we'd already had our first eight customer downloads. Wow, those people must really want the latest stuff! :)

The 61121 release was all about addressing some of the biggest pain points for our customers. Of particular note were two workarounds for ASP.NET AJAX Beta 2 issues:

  • The first addresses an issue where the Toolkit had a hard dependency on Microsoft.Web.Extensions.Design.dll, a file that isn't installed by ASP.NET AJAX Beta 2 on machines that don't have some flavor of Visual Studio already installed. This dependency can cause obvious issues for web servers since they usually do not have development tools like Visual Studio installed.
  • The second addresses an issue where ASP.NET AJAX Beta 2 doesn't render the ScriptManager/extenders out to the page during an async postback if EnableEventValidation=false - meaning that the relevant extenders simply don't get recreated after an UpdatePanel postback. We reported this issue to the ASP.NET AJAX team prior to Beta 2, but there wasn't time for them to fix it in that release (don't worry, they'll be fixing it in their next release!). We'd implemented a workaround for this issue in our earlier 61106 release, but it applied only to CascadingDropDown (which is the only control that requires EnableEventValidation=false). Subsequent customer feedback prompted us to move that workaround up a level for this release so that it now applies to the entire Toolkit.

In addition to those two "big ticket" items, we also fixed a handful of other issues, most of which we chose based on customer feedback and work item voting on CodePlex. (Voting is a fairly recent addition - have a look at how it focuses attention on issues that are important to the community!). The other fixes in the 61121 release address the most popular issues in our CodePlex queue and include fixes for ModalPopup server-side show/hide, ClientState within an UpdatePanel, Accordion pane size updates, multiple DragDrop panels, CommonToolkitScripts, and web.config updates to get things working seamlessly with IIS7.

This being small-scale release, we didn't have time to include any new controls this time around. :( However, that's an explicit goal for an upcoming release which we hope to make available before the end of the year. We've got some neat stuff in the prototype stage and it'll be great to get some of it polished and released to the world!

Recall that you can sample any of the controls right now (no install required). Then you can browse the project web site, download the latest Toolkit, and start creating your own controls and/or contributing to the project!

If you have any feedback, please share it with us on the support forum (or email me)!

Dynamic content made easy *redux* [How to: Use the new dynamic population support for Toolkit controls]

I previously blogged a sample demonstrating how to use the AJAX Control Toolkit's dynamic population functionality with a data-bound ModalPopup. That sample was well received, but some of the changes that happened as part of the ASP.NET AJAX Beta 1 and Beta 2 releases have rendered the sample code I originally posted un-runnable on current builds.

No worries - it's a simple matter to update the sample and the exercise should serve as a good example of some of the things that need to be done as part of an upgrade. (For a far more in depth guide to upgrading, please refer to Shawn's AJAX Control Toolkit Migration Guide and follow-up about upgrading Web Services/Methods.)

Referring to the sample code I posted earlier as a starting point, the 5 things we need to do to update it are:

  1. Change the tag prefix for ScriptManager from "atlas" to "asp" to point to the new location for ScriptManager
  2. Change the @Register tag to refer to the AjaxControlToolkit by its new name ("AtlasControlToolkit"->"AjaxControlToolkit" twice and "atlasToolkit"->"ajaxToolkit" once)
  3. Change the corresponding tag prefix for ModalPopupExtender from "atlasToolkit" to "ajaxToolkit"
  4. Copy the properties of the ModalPopupProperties element to the ModalPopupExtender element and remove the empty ModalPopupProperties element now that the XxxProperties elements are no longer used
  5. Update the web method definition by making the GetContent method static and adding the [Microsoft.Web.Script.Services.ScriptMethod] attribute

That's it! As you can see, it's mostly simple "find-and-replace" naming changes that can easily be applied to an entire site at once. The XxxProperties change is slightly more involved, but requires very little effort since it's basically just a "cut-and-paste" operation. The web method changes are also a little bit of effort, but the changes themselves are simple and it's easy to find where to make them by searching for the pre-existing "WebMethod" attribute. Nothing here is risky or error-prone and - with the exception of the web method changes - the compiler will report all of them as errors until they're fixed correctly.

For completeness, here's a reminder of what dynamic population looks like in action:

Animated demonstration

And here's the complete sample code after the changes discussed above have been applied. This sample runs fine on the ASP.NET AJAX Beta 2 and the AJAX Control Toolkit 61106 release:

<%@ Page Language="C#" %>
<%
@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit"
  TagPrefix="ajaxToolkit" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<
script runat="server">
  [System.Web.Services.WebMethod]
  [Microsoft.Web.Script.Services.
ScriptMethod]
  
public static string GetContent(string contextKey)
  {
    
// Create a random color
    string color = (new Random()).Next(0xffffff).ToString("x6");
    
// Use the style specified by the page author
    string style = contextKey;
    
// Display the current time
    string time = DateTime.Now.ToLongTimeString();
    
// Compose the content to return
    return "<span style='color:#" + color + "; " + style + "'>" + time + "</span> ";
  }
</script>

<
html xmlns="http://www.w3.org/1999/xhtml">
<
head id="Head1" runat="server">
  <title>Dynamic ModalPopup Demonstration</title>

  <%-- Style the page so it looks pretty --%>
  
<style type="text/css">
    body { font-family:Verdana;     font-size:10pt; }
    
.background { background-color:Gray; }
    
.popup { width:200px;             padding:10px;        background-color:White;
            
border-style:solid;      border-color:Black;  border-width:2px;
            
vertical-align: middle;  text-align:center; }
  
</style>
</
head>
<
body>
  <form id="form1" runat="server">

    <%-- Atlas pages need a ScriptManager --%>
    
<asp:ScriptManager ID="ScriptManager1" runat="server" />

    <%-- A very simple data source to drive the demonstration --%>
    
<asp:XmlDataSource ID="XmlDataSource1" runat="server">
      <Data>
        <items>
          <item style="font-weight:bold" />
          <item style="font-style:italic" />
          <item style="text-decoration:underline" />
        </items>
      </Data>
    </asp:XmlDataSource>

    <%-- A simple list of all the data items available --%>
    
<asp:DataList ID="DataList1" runat="server" DataSourceID="XmlDataSource1">

      <HeaderTemplate>
        How would you like your dynamic content styled?
      
</HeaderTemplate>

      <ItemTemplate>
        &bull; <asp:LinkButton ID="LinkButton" runat="server" Text='<%# Eval("style") %>' />

        <%-- The ModalPopupExtender, popping up Panel1 and dynamically populating Panel2 --%>
        
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender" runat="server"
            TargetControlID="LinkButton" PopupControlID="Panel1" OkControlID="Button1"
            BackgroundCssClass="background" DynamicControlID="Panel2"
            DynamicContextKey='<%# Eval("style") %>' DynamicServiceMethod="GetContent" />
      </ItemTemplate>

    </asp:DataList>

    <%-- All ModalPopups share the same popup --%>
    
<asp:Panel ID="Panel1" runat="server" CssClass="popup" style="display:none;">
      <p>This popup popped at <asp:Label ID="Panel2" runat="server" /> and all was well.</p>
      <p><asp:Button ID="Button1" runat="server" Text="OK" /></p>
    </asp:Panel>

  </form>
</
body>
</
html>

Enjoy!

Just what it takes for Beta 2 [AJAX Control Toolkit update!]

On Monday we made available the 61106 release of the AJAX Control Toolkit. We did this in parallel with the release of ASP.NET AJAX v1.0 Beta 2 in order to accommodate some breaking changes introduced in that release. As such, we did not make any functional changes to the Toolkit in the 61106 release, though we did take the opportunity to fix one or two small bugs that we'd found.

Recall that you can sample any of the controls right now (no install required). Then you can browse the project web site, download the latest Toolkit, and start creating your own controls and/or contributing to the project!

If you have any feedback, please share it with us on the support forum (or email me)!

Talked Toolkit [Spoke at the ASP.NET Connections conference]

As I blogged earlier, I presented the AMS302: "Atlas" AJAX Control Toolkit Unleashed: Creating Rich Client-Side Controls and Components session at the Microsoft ASP.NET Connections conference a few hours ago. This was my first ever presentation at a conference and it was a lot of fun! I hope those of you who attended enjoyed the talk and learned more about the Toolkit - it was great to have an opportunity to talk to you in person!

I've attached my slide deck and the demo content to this post so that anyone who's interested can download it and play around on their own machines.

We're always looking for more contributors and additional control ideas, so please let me know if you want to contribute!

[AMS302-AjaxControlToolkit.zip]

ASP.NET AJAX née "Atlas" - and all that entails... [AJAX Control Toolkit update!]

It wasn't as easy as anybody claimed it would be, but my team just published the 61020 release of the AJAX Control Toolkit (formerly the "Atlas" Control Toolkit)!

What's new in this release? Umm, pretty much everything. :)

Kidding aside, we probably touched just about every line of code in the Toolkit during this release. Why? Well, because we sim-shipped (simultaneously shipped) with the new ASP.NET AJAX v1.0 Beta, a pretty fundamental set of changes to the framework formerly code named "Atlas". The many changes are detailed on their web site, so I won't bore you with the details here. Suffice it to say that their changes impacted the Toolkit in a major way since we build directly on top of them. Some of the specifics of the Toolkit migration process itself are detailed on Shawn's blog, so I won't repeat them here, either.

What I *will* do is highlight our new controls for this release:

I'd also like to single out four of our contributors who made significant contributions to the code that's part of this particular release. To be sure, we have other contributors who've been tremendously helpful in numerous ways and who we'd be lost without. However, these four folks made specific contributions to this release that were very much appreciated. My new best friends are:

And thanks to *everyone* who helped get this release out the door!

As usual, the release notes outline a bunch of other changes we've made. Please take a moment to read about the new stuff. While you're at it, sample any of the controls right now (no install required). Then browse the project web site and download the latest Toolkit so you can start creating your own controls and/or contributing to the project!

If you have any feedback, please share it with us on the support forum (or email me)!!

Talkin' Toolkit [Speaking at the ASP.NET Connections conference in November]

I'll be presenting the AMS302: "Atlas" Control Toolkit Unleashed: Creating Rich Client-Side Controls and Components session at the Microsoft ASP.NET Connections conference on November 7th in Las Vegas. The session's description is:

The "Atlas" Control Toolkit is a set of controls and extenders designed to help ASP.NET developers easily integrate rich client UI features into their Web applications. As a community effort, the Toolkit contains controls written by Microsoft and non-Microsoft developers who have joined forces to create a powerful, shared-source library for all to use. You will learn how to integrate Toolkit components into your application as well as get an idea of how easy it is to create "Atlas" extenders using the Toolkit.

If you will be attending the conference (or otherwise in the area) and would like to get together, please let me know and we'll make plans!

Dynamic content made easy [How to: Use the new dynamic population support for Toolkit controls]

One of the more frequent requests we've gotten for the "Atlas" Control Toolkit is some way to easily alter the content of a popup before displaying it to the user. Typically, page authors want to have a single popup element on their page that is used from multiple locations (often the rows of a data-bound server control) and they want the popup to display information specific to each location that displays it. For example, a page displaying multiple products might want a popup associated with each product to display additional details for that particular product.

There was previously no easy way to accomplish this task, but with the 60914 release of the Toolkit, we've made it simple! The HoverMenu, ModalPopup, and PopupControl now all derive from new DynamicPopulate*Base classes (see the "Other neat stuff" page for details) and automatically expose four new properties: DynamicControlID, DynamicContextKey, DynamicServicePath, and DynamicServiceMethod. These properties behave just like they do for the DynamicPopulate control (please follow that link for more details) and the existing controls have been modified to call the "populate" function as part of their popup actions.

What this means for page authors is that it's simple to add dynamic population to new/existing pages - what it means for control authors is that it's simple to add dynamic population to new/existing controls!

Here's what dynamic population looks like in action (I've arbitrarily chosen ModalPopup for the demonstration):

Animated demonstration

The complete code for the sample follows; noteworthy sections have been bolded to make them stand out. The important things to note are:

  • The page content is generated by data binding an XmlDataSource to a DataList. The data are simple CSS style declarations that are used to decorate the dynamic content when it renders. The user can select which decoration to apply by choosing any of the links on the page.
  • Each row of the DataList includes a ModalPopupExtender declaration that pops a modal panel when the CSS style declaration is clicked. All ModalPopupsExtenders share the same popup element in order to avoid unnecessary duplication. The text of the row and the DynamicContextKey of the ModalPopupProperties are both set by a (data bound) call to Eval.
  • The popup (Panel1) contains both static content and dynamic content (Panel2). The static content includes the "OK" button that dismisses the popup. The dynamic content consists of the current server time which is styled according to the selected row's CSS style declaration and displayed in a random color.
  • The dynamic content is generated by a page method which uses its context key parameter to identify the specific row that is being dynamically populated. (Here, the context key is the CSS style declaration, but typically it might be a database index or row number.)

That's all there is to it!

Just save the following code to an .ASPX file in the SampleWebSite directory of a Toolkit installation if you want to try it out for yourself:

<%@ Page Language="C#" %>
<%
@ Register Assembly="AtlasControlToolkit" Namespace="AtlasControlToolkit"
  TagPrefix="atlasToolkit" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<
script runat="server">
  [System.Web.Services.WebMethod]
  
public string GetContent(string contextKey)
  {
    
// Create a random color
    string color = (new Random()).Next(0xffffff).ToString("x6");
    
// Use the style specified by the page author
    string style = contextKey;
    
// Display the current time
    string time = DateTime.Now.ToLongTimeString();
    
// Compose the content to return
    return "<span style='color:#" + color + "; " + style + "'>" + time + "</span> ";
  }
</script>

<
html xmlns="http://www.w3.org/1999/xhtml">
<
head runat="server">
  <title>Dynamic ModalPopup Demonstration</title>

  <%-- Style the page so it looks pretty --%>
  
<style type="text/css">
    body { font-family:Verdana;     font-size:10pt; }
    
.background { background-color:Gray; }
    
.popup { width:200px;             padding:10px;        background-color:White;
            
border-style:solid;      border-color:Black;  border-width:2px;
            
vertical-align: middle;  text-align:center; }
  
</style>
</
head>
<
body>
  <form id="form1" runat="server">

    <%-- Atlas pages need a ScriptManager --%>
    
<atlas:ScriptManager ID="ScriptManager1" runat="server" />

    <%-- A very simple data source to drive the demonstration --%>
    
<asp:XmlDataSource ID="XmlDataSource1" runat="server">
      <Data>
        <items>
          <item style="font-weight:bold" />
          <item style="font-style:italic" />
          <item style="text-decoration:underline" />
        </items>
      </Data>
    </asp:XmlDataSource>

    <%-- A simple list of all the data items available --%>
    
<asp:DataList ID="DataList1" runat="server" DataSourceID="XmlDataSource1">

      <HeaderTemplate>
        How would you like your dynamic content styled?
      
</HeaderTemplate>

      <ItemTemplate>
        &bull; <asp:LinkButton ID="LinkButton" runat="server" Text='<%# Eval("style") %>' />

        <%-- The ModalPopupExtender, popping up Panel1 and dynamically populating Panel2 --%>
        
<atlasToolkit:ModalPopupExtender ID="ModalPopupExtender" runat="server">
          <atlasToolkit:ModalPopupProperties
            TargetControlID="LinkButton" PopupControlID="Panel1" OkControlID="Button1"
            BackgroundCssClass="background" DynamicControlID="Panel2"
            DynamicContextKey='<%# Eval("style") %>' DynamicServiceMethod="GetContent" />
        </atlasToolkit:ModalPopupExtender>
      </ItemTemplate>

    </asp:DataList>

    <%-- All ModalPopups share the same popup --%>
    
<asp:Panel ID="Panel1" runat="server" CssClass="popup" style="display:none;">
      <p>This popup popped at <asp:Label ID="Panel2" runat="server" /> and all was well.</p>
      <p><asp:Button ID="Button1" runat="server" Text="OK" /></p>
    </asp:Panel>

  </form>
</
body>
</
html>

If you found this "How to" helpful or if you have any suggestions for ways in which future "How to"'s could be improved, please let me know. Thank you!!